0

What C or C++ program prints Fibonacci series?

What algorithm should I use to print out Fibonacci series in C++ or C?

11th Aug 2020, 9:10 AM
Hilary
Hilary - avatar
1 Odpowiedź
+ 1
Hi, You can use following algorithm : using iteration: Procedure Fibonacci(n) declare f0, f1, fib, loop set f0 to 0 set f1 to 1 display f0, f1 for loop ← 1 to n fib ← f0 + f1 f0 ← f1 f1 ← fib display fib end for end procedure using recursion: START Procedure Fibonacci(n) declare f0, f1, fib, loop set f0 to 0 set f1 to 1 display f0, f1 for loop ← 1 to n fib ← f0 + f1 f0 ← f1 f1 ← fib display fib end for END Note:For c and C++ algorithm will be remain same but syntax will change as per language.
11th Aug 2020, 9:19 AM
AjayGohil