Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created May 17, 2022 10:14
Show Gist options
  • Save igorvanloo/4e7ec12310aec8dd8772da9155bb0b5a to your computer and use it in GitHub Desktop.
Save igorvanloo/4e7ec12310aec8dd8772da9155bb0b5a to your computer and use it in GitHub Desktop.
p235
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