// What is the index of the first term in the Fibonacci sequence to contain
// 1000 digits?
#include <iostream>
#include <math.h>
int main(int argc, constchar * argv[])
{
longdouble fibonacciRatio = (1.618);
// d = b log a where d is number of digits b is power and a is base.
// digits = 999 since log is base 10
double power = 999/log10(fibonacciRatio);
std::cout << power << " ";
// add one to power for beginning ratio size
power++;
std::cout << power;
// enter both to check
return 0;
}
I came up with what i thought was an inventive way to tackle this problem and my solution gives me the right answer but I can't help but feel like maybe I just got lucky. Gave me 4780.4 and 4781.4. Rounded both, 4782 was right.