Skip to content

Instantly share code, notes, and snippets.

@mizushou
Created October 29, 2017 23:25
Show Gist options
  • Save mizushou/1486b046cfbd62b6f4d84db40ba5751d to your computer and use it in GitHub Desktop.
Save mizushou/1486b046cfbd62b6f4d84db40ba5751d to your computer and use it in GitHub Desktop.
# フィボナッチ数列
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