0

print the series 0 1 1 2 3 5 8.....n terms

25th Jul 2016, 4:27 PM
Ritwik Singhal
Ritwik Singhal - avatar
2 Respuestas
+ 1
Add scanner to define n.
27th Jul 2016, 10:51 AM
LemonVolts
LemonVolts - avatar
0
public class Program { public static void main(String[] args) { int fib1=0; int fib2=1; int fibonacci; System.out.println(fib1); System.out.println(fib2); for (int i=1;i<n;i++) { fibonacci=fib1+fib2; fib1=fib2; fib2=fibonacci; System.out.println(fibonacci); } } }
25th Jul 2016, 5:15 PM
Valentino Picone
Valentino Picone - avatar