fork(1) download
  1. /* フィボナッチ数列 */
  2.  
  3. class Suretsu {
  4. public static void main(String[] args) {
  5. long l1=0L;
  6. long l2=1L;
  7. System.out.print("0 1 ");
  8. for (int i = 1; i <45; i++) {
  9. long c=l1+l2;
  10. System.out.print(Long.toString(c)+" ");
  11. l1=l2;l2=c;
  12. if (i % 10 == 9) {
  13. System.out.println();
  14. }
  15. }
  16. }
  17. //こんなもん要らん
  18. public static long fibonacci(long n) {
  19. if (n == 0L) {
  20. return 0L;
  21. } else if (n == 1L) {
  22. return 1L;
  23. } else /* n >= 2L */ {
  24. return fibonacci(n - 2L) + fibonacci(n - 1L);
  25. }
  26. }
  27. }
Success #stdin #stdout 0.05s 27728KB
stdin
Standard input is empty
stdout
0 1 1 2 3 5 8 13 21 34 55 
89 144 233 377 610 987 1597 2584 4181 6765 
10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 
1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 
165580141 267914296 433494437 701408733 1134903170