From c9c8113afe5f2dc8b5cb7491af689626e16b366e Mon Sep 17 00:00:00 2001 From: David Lee <913305994@qq.com> Date: Sun, 4 Mar 2018 13:23:17 +0800 Subject: [PATCH] Fibonacci --- "\350\266\205\347\272\247\346\245\274\346\242\257.py" | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 "\350\266\205\347\272\247\346\245\274\346\242\257.py" diff --git "a/\350\266\205\347\272\247\346\245\274\346\242\257.py" "b/\350\266\205\347\272\247\346\245\274\346\242\257.py" new file mode 100644 index 0000000..7b270c6 --- /dev/null +++ "b/\350\266\205\347\272\247\346\245\274\346\242\257.py" @@ -0,0 +1,9 @@ +n=5 +def fei(n): + if n == 1 or n == 2: + return 1 + elif n > 2: + return fei(n-1) + fei(n-2) + else: + return 0 +print(fei(n))