Note that this solution will overflow when given a prod value higher than fib(47) * fib(48), as fib(48) * fib(49) > u64::MAX. On a release build, the a * b multiplication won't panic and the while loop becomes an infinite loop.
Granted, the vast majority of solutions here suffer from unchecked multiplications, this one is hardly alone.
Note that this solution will overflow when given a
prod
value higher thanfib(47) * fib(48)
, asfib(48) * fib(49) > u64::MAX
. On a release build, thea * b
multiplication won't panic and the while loop becomes an infinite loop.Granted, the vast majority of solutions here suffer from unchecked multiplications, this one is hardly alone.
Your approach is way too slow.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution