Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace epka
  5. {
  6.     class Program
  7.     {
  8.         static int licz = 0;
  9.         /*static int Sil (int n)
  10.  
  11.         {
  12.             Console.WriteLine(n);
  13.             if (n == 0) return 1;
  14.             else return n * Sil(n - 1);
  15.         }*/
  16.         static int Fib(int n)
  17.         {
  18.             //Console.WriteLine(n);
  19.             licz++;
  20.             if (n == 0) return 1;
  21.             if (n == 1) return 1;
  22.             else return Fib(n - 1)+ Fib(n - 2);
  23.         }
  24.  
  25.         static void Main(string[] args)
  26.         {
  27.             int n, w;
  28.             Console.WriteLine("Podaj n:");
  29.             n = int.Parse(Console.ReadLine());
  30.             DateTime czas = DateTime.Now;
  31.             //w = Sil(n);
  32.             Console.WriteLine("{0}! = {1}", n, Fib(n));
  33.             DateTime czas1 = DateTime.Now;
  34.             Console.WriteLine("Czas operacji:{0}", czas1.Ticks - czas.Ticks);
  35.             Console.WriteLine(licz);
  36.             Console.ReadKey();
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement