Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("This calculates the sum of the cubes of the 1st natural numbers")
- natn = eval(input("How many cube numbers do you want to sum? "))
- print("sum of even cubes between 0 and {} : ".format(natn-1),sum(i**3 for i in range(0,natn,2)),"\n",
- "sum of cubes between 0 and {}".format(natn-1),sum(i**3 for i in range(natn)),"\n",
- "average of cubees between 0 and {}".format(natn-1),sum(i**3 for i in range(natn))/sum(1 for i in range(natn)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement