From 7273eebf3f6549fe96579205085cd930d3cbd7c2 Mon Sep 17 00:00:00 2001 From: p6voizrua <15517311810@qq.com> Date: Tue, 15 Feb 2022 22:30:36 +0800 Subject: [PATCH] ADD file via upload --- 斐波那契数列.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 斐波那契数列.c diff --git a/斐波那契数列.c b/斐波那契数列.c new file mode 100644 index 0000000..0ac8efc --- /dev/null +++ b/斐波那契数列.c @@ -0,0 +1,18 @@ +#include +int fib(int n) +{ + if (n == 1 || n == 2) + return 1; + else + return fib(n - 1) + fib(n - 2); +} +int main() +{ + int n; + scanf("%d", &n); + int i; + for (i = 1; i <= n; i++) + printf("%d ", fib(i)); + return 0; +} +