fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. ArrayList<Integer> al = new ArrayList<Integer>();
  14. al.add(0);
  15. al.add(1);
  16. int size = 15;
  17. //System.out.print(al.get(0) + " ");
  18. //System.out.print(al.get(0) + " ");
  19. for(int i=2; i<=size; i++)
  20. {
  21. al.add(al.get(i-1)+al.get(i-2));
  22. //System.out.print(al.get(i) + " ");
  23. }
  24. System.out.print(al);
  25. }
  26. }
Success #stdin #stdout 0.1s 52608KB
stdin
Standard input is empty
stdout
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]