#include <stdio.h>
int fibonacci(int n) {
if (n == 1 || n == 2)
return 1;
return fibonacci(n - 1) + fibonacci(n - 2);
}
void main() {
int month = 1, n, sum = 0;
scanf("%d", &n);
while ((sum = fibonacci(month)) < n) {
month++;
}
printf("至少到第%d个月时,才有%d对兔子,已有%d对兔子\n", month, n, sum);
}
来源:CSDN
作者:轻松的小希
链接:https://blog.csdn.net/qq_38490457/article/details/104647118