
import sympy as sp
k = sp.symbols('k', integer=True)
a = 1
r = sp.Rational(1, 2)
total_dist = sp.Sum(r**k, (k, 0, sp.oo)).doit()
print(f'Infinite sum distance: {total_dist} m')
assert total_dist == 2
print('Assertion PASSED: Total distance = 2 meters')
Only each person's first answer, given before viewing the solution, is counted.
Discussion 0 comments
Log in to join the discussion.