Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 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 FibonacciSeriesInCSharp
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int i, nOne = 0, nTwo = 1, next;
  14.  
  15. Console.WriteLine("Enter a Number");
  16. int n = Convert.ToInt32(Console.ReadLine());
  17.  
  18. Console.WriteLine("Fibonacci Series are");
  19.  
  20. for (i = 0; i < n; i++)
  21. {
  22. if (i<=1)
  23. {
  24. next = i;
  25. }
  26. else
  27. {
  28. next = nOne + nTwo;
  29. nOne = nTwo;
  30. nTwo = next;
  31. }
  32. Console.WriteLine(next);
  33. }
  34. Console.ReadLine();
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement