Skip to content

Instantly share code, notes, and snippets.

@aoirint
Created July 20, 2017 12:46
Show Gist options
  • Save aoirint/8cdef6c764da1590ea2b708cc40c4fbb to your computer and use it in GitHub Desktop.
Save aoirint/8cdef6c764da1590ea2b708cc40c4fbb to your computer and use it in GitHub Desktop.
Javaでフィボナッチ数列のテスト
public class Fibo {
static int fibo(int i) {
if (i == 1) return 0;
if (i == 2) return 1;
return fibo(i-1) + fibo(i-2);
}
public static void main(String[] args) {
for (int i=1; i<31; i++) {
System.out.println(fibo(i));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment