0
How the logic works?
public static void Main() { int n; int a = 0; int b = 1; Console.Write("Enter the limit : "); n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { Console.WriteLine(a); int temp = a; a = b; b = temp + b; } Console.Read();
2 Antworten
+ 4
n - no. of values to print.
temp - temporary variable for the purpose of swapping a and b.
In fibonacci series the next umber is determined by adding the number at current position and previous position.
Here, we print a number and swap it to a temporary variable then get the next number from b to a, then we get the next to next number on b by adding the current and last number.
0
マυѕту thanks bro