fork download
  1. public class Main {
  2.  
  3. public static void main(String[] args) {
  4. // Expected output: 0, 1, 1, 2, 3, 5, 8, 13, 21
  5. for (int i = 0; i < 9; i++) {
  6. System.out.println(getFibonnaciNumber(i));
  7. }
  8. }
  9.  
  10. /*
  11.   Gets the fibonnaci number at the nth index.
  12.   Fibonacci numbers form a sequence in which each number is the sum of the two preceding ones.
  13.  
  14.   Example:
  15.   F(0) = 0
  16.   F(1) = 1
  17.   F(2) = 1 (0+1)
  18.   F(3) = 2 (1+1)
  19.   F(4) = 3 (2+1)
  20.   F(5) = 5 (3+2)
  21.   */
  22. private static int getFibonnaciNumber(int n) {
  23. return -1;
  24. }
  25. }
Success #stdin #stdout 0.09s 54608KB
stdin
Standard input is empty
stdout
-1
-1
-1
-1
-1
-1
-1
-1
-1