diff --git a/斐波那契数列.cpp b/斐波那契数列.cpp new file mode 100644 index 0000000..e021348 --- /dev/null +++ b/斐波那契数列.cpp @@ -0,0 +1,17 @@ +#include +long Fib(int n) +{ + if(n == 0) + return 0; + if(n == 1) + return 1; + else + return Fib(n - 1)+Fib(n - 2); +} +int main() +{ + int n=0; + scanf("%d",&n); + printf("%d\n",Fib(n)); + return 0; +}