Advertisement
Blagovest

FibonacciNumbers

Oct 9th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Hello_Name_
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int number = int.Parse(Console.ReadLine());
  14. Console.WriteLine(PrintFib(number));
  15. }
  16. static int PrintFib(int number)
  17. {
  18. int a = 0;
  19. int b = 1;
  20. for (int i = 0; i<=number; i++)
  21. {
  22. int fibNumber =a;
  23. a =b;
  24. b = fibNumber+b;
  25. }
  26. return a;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement