Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool PotpunKvadrat(int x)
- {
- int k=sqrt(x);
- if (k*k==x) return true;
- return false;
- }
- bool FibBroj(int n)
- {
- if (PotpunKvadrat(5*n*n+4) || PotpunKvadrat(5*n*n-4)) return true;
- return false;
- }
- int main()
- {
- int n;
- cin>>n;
- if (FibBroj(n)) cout<<"Broj "<<n<<" jeste Fibonacijev broj"<<endl;
- else cout<<"Broj "<<n<<" nije Fibonacijev broj"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement