Created
May 17, 2022 10:14
-
-
Save igorvanloo/4e7ec12310aec8dd8772da9155bb0b5a to your computer and use it in GitHub Desktop.
p235
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def u(k, r): | |
return (900 - 3*k)*pow(r, k-1) | |
def s(n, r): | |
total = 0 | |
for k in range(1, n+1): | |
total += u(k, r) | |
return total | |
def compute(): | |
r = "1." | |
goal = -600000000000 | |
while len(r) != 16: | |
for x in range(0, 10): | |
r1 = float(r + str(x)) | |
if s(5000, r1) < goal: | |
r += str(x - 1) | |
break | |
return round(float(r), 12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment