Project Euler 267 - Billionaire

Official link: https://projecteuler.net/problem=267

Thought Process

Been struggling hard on the 250-270 problems, this problem is easy in comparison to the rest in this range

Now we know what to do here, find when the derivative is equal to 0

We don't actually need such an accurate f , if 1.3 < f < 1.6 it should work, because all of these values of f result in at-least 432 heads to reach a billion, therefore the answer is simply the below

Reason: Once we reach 432 we have won a billion, so any heads after this we also win a billion, and there are 2^1000 possibilities when flipping a thousand coins

Interactive Code

No interactive code for this problem

Code is given below, along with a function to find the optimal f without derivatives