( 數論專題 )【 斐波那契通項公式 + 等比數列求和公式 】
斐波那契通項公式( 證明略 ):
例題:
求當n趨向於無窮大,Sn等於什麼,輸出最簡分數。
分子是斐波那契數列,分母是K的 i 次方, K是給定的。
思路:
代碼:
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int T;cin>>T;
while ( T-- ) {
int k;cin>>k;
int up=k,down=k*k-k-1;
int gcd = __gcd(up,down);
up/=gcd;down/=gcd;
if ( down==1 ) cout << up << endl;
else cout << up << "/" << down << endl;
}
return 0;
}