+ 2
Please modify my code fibonacci series
public class FibonacciSeries { public static void main(String [] args) { int n = Integer.parseInt(args[0]); int a = 1,b = 1,k = 0; System.out.print("0 1 1 "); while(k < n) { k = a + b; System.out.print(k +" "); a = b; b = k; } } } output : FibanacciSeries 10 0 1 1 2 3 5 8 13 guys that is the actual output but 13 must not print only up to 8 it must be printed can any one modify the code for my requirment.
1 Réponse
0
may be you should add an if statement to your code that test that k is less than args[0]:
if(k<args[0])
break;