#include <stdio.h>
void fibonacci(int n) {
int i, num1 = 0, num2 = 1, nextNum;
printf("Fibonacci series up to %d terms:\n", n);
for (i = 1; i <= n; ++i) {
printf("%d, ", num1);
nextNum = num1 + num2;
num1 = num2;
num2 = nextNum;
}
}
int main() {
int num;
printf("Enter the number of terms: ");
scanf("%d", &num);
fibonacci(num);
return 0;
}
标签:nextNum,num1,num2,int,打印,num,Fibonacci,printf,数列 From: https://blog.51cto.com/u_16284467/8505998