❔ Trying to make a bit of code to display all values of fibonacci until the nth term input
Have got this so far (i am a beginner)
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Fibonacci(n));
public static int Fibonacci(int x) {
int first = 1;
int second = 2;
int next = 3;
for (int i = 3; i <= x; i++){
next = first + second;
Console.WriteLine("{0}", next);
first = second;
second = next;
}
}
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Fibonacci(n));
public static int Fibonacci(int x) {
int first = 1;
int second = 2;
int next = 3;
for (int i = 3; i <= x; i++){
next = first + second;
Console.WriteLine("{0}", next);
first = second;
second = next;
}
}
