Created
October 29, 2017 23:25
-
-
Save mizushou/1486b046cfbd62b6f4d84db40ba5751d 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
class Fibonacci { | |
static int fib(int n) { | |
//引数でn=0,1を指定した際は再帰処理を行わず、即座に1を返す | |
if(n<=1) return 1; | |
return fib(n-1) + fib(n-2); | |
} | |
public static void main(String[] args) { | |
System.out.println(fib(0)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment