There was another conveyance Fibonacci number column: F0 = 7, F1 = 11, Fn = Fn-1 + Fn-2 (n≥2).
Input Format
Input data composed of multiple rows, each row is an integer n (n <10 ^ 6).
Output Format
If the Fn be divisible by 33, then print a line "yes"
, otherwise, print one line "no"
.
#include <iostream>
using namespace std;
long long F[1000001];
void Fib() {
F[0] = 7;
F[1] = 11;
for (int i = 2; i <= 1000000; i++) {
F[i] = (F[i - 1] + F[i - 2]) % 3 ;
}
}
int main() {
int n;
Fib();
while (cin >> n) {
if (F[n] % 3 == 0) cout << "yes" << endl;
else cout << "no" << endl;
}
return 0;
}