Skip to content

Instantly share code, notes, and snippets.

@xhiroga
Created November 28, 2017 22:30
Show Gist options
  • Save xhiroga/07f67e59996626075f9ae0332603093c to your computer and use it in GitHub Desktop.
Save xhiroga/07f67e59996626075f9ae0332603093c to your computer and use it in GitHub Desktop.
シングルスレッドで再帰的にフィボナッチ数列を計算するプログラム
public class Fib {
public static int fib(int n){
if (n == 0){
return 0;
} else if(n == 1){
return 1;
} else {
return fib(n-1) + fib(n-2);
}
}
public static void main(String args[]){
System.out.println(fib(45));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment