1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 21:58:41 +00:00
202401-programming-assignments/【实践课内】5.循环结构2/7-2 循环-奇怪的斐波那契数列.c

23 lines
328 B
C
Raw Normal View History

2024-10-30 02:26:56 +00:00
#include <stdio.h>
int main() {
int n, f,
f_pre2 = 7, f_pre1 = 11;
scanf("%d", &n);
for (int i = 2; i <= n; i++) {
f = (f_pre1 + f_pre2) % 3;
f_pre2 = f_pre1;
f_pre1 = f;
}
if (f == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}