There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).
Input
Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000).
Output
Print the word "yes" if 3 divide evenly into F(n).
Print the word "no" if not.
Sample Input
0 1 2 3 4 5
Sample Output
no no yes no no no
前三十中被三整除的数

可以清楚的看到n%4==2,即规律。
代码:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int a[104];
int main()
{
int n;
while(cin>>n)
{
if(n%4==2)
{
cout<<"yes"<<endl;
}
else
{
cout<<"no"<<endl;
}
}
return 0;
}
本文探讨了一种特殊的斐波那契数列,其初始值为F(0)=7和F(1)=11,之后的每一项遵循斐波那契数列的传统递归规则。通过观察,我们发现了一个有趣的现象:当n模4等于2时,F(n)能够被3整除。文章提供了一段C++代码,用于快速判断给定的n值对应的斐波那契数是否能被3整除。
629

被折叠的 条评论
为什么被折叠?



