Fibonacci series in java

preview_player
Показать описание
#techlearners #java #fibonacci
Fibonacci series is a series in which first element is 0 second is 1 and remaining are calculated by sum of immediate previous two elements
0, 1, 1, 2, 3, 5, 8, .......

Logic
Store first element in variable a
Store second element in variable b
print both elements
input number of elements in the series to be printed in n
loop till n-2
c=a+b
print c
a=b
b=c
Рекомендации по теме