fork download
  1. class Main {
  2. public static void main (String args [])
  3. {
  4. int n1=0, n2=1, n3, i, count=10;
  5. System.out.print(n1+" "+n2); //printing 0 and 1
  6. for (i=2; i<count; ++i)//loop starts from 2 because 0 and 1 are already printed
  7. {
  8. n3=n1+n2;
  9. System.out.print(" "+n3);
  10. n1=n2;
  11. n2=n3;
  12. }
  13. }
  14. }
  15.  
Success #stdin #stdout 0.22s 43076KB
stdin
Standard input is empty
stdout
0 1 1 2 3 5 8 13 21 34