You are viewing a single comment's thread. Return to all comments →
C++ solution :
map<long, long> fibo; long fibonacci(long n) { if (fibo.find(n)!=fibo.end()) return fibo[n]; fibo[n]=fibonacci(n-1)+fibonacci(n-2); return fibo[n]; } string solve(long n) { fibo[0]=0; fibo[1]=1; long i=0; while(fibonacci(i)<n) i++; if (fibonacci(i)!=n) return "IsNotFibo"; return "IsFibo"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Is Fibo
You are viewing a single comment's thread. Return to all comments →
C++ solution :