Created
November 28, 2017 22:30
-
-
Save xhiroga/07f67e59996626075f9ae0332603093c to your computer and use it in GitHub Desktop.
シングルスレッドで再帰的にフィボナッチ数列を計算するプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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