""" Goal/purpose: This is a debugging exercise to be solved in class. This program attempts to calculate e using its infinite series e = sum(1/k!) for k from 0 to infinity. (Recall 0! = 1 by definition) The correct answer is 2.7182818284590451, but the program (as written) doesn't find it. Please fix the problem. Author: George Gollin File: unit04_in_class_warmup_solution.py Date: January 26, 2017 Physics 298 owl, University of Illinois at Urbana-Champaign """ print("\nthe correct answer is 2.7182818284590451...") # Define and initialize variables, then loop sum = 1.0 k = 0 kfactorial = 1 number_of_terms = 10 # here's the loop while k < number_of_terms: k = k + 1 kfactorial = kfactorial * k sum = 1 / kfactorial print("e = ", sum) # all finished.