Sum of a Power Series
Programs with input · Intermediate · about 8 min
Read two whole numbers, x and then n, one per line (n is 0 or more). The series is 1 + x + x**2 + x**3 + ... + x**n. Print its terms on one line, separated by single spaces, as Terms: 1 2 4 8 16, then their total as Sum: 31.
The prompts inside input() are not checked, only what you print.
Example
You type:
2 4
The program prints:
Terms: 1 2 4 8 16 Sum: 31
x = int(input("x: "))
n = int(input("n: "))
# Print the terms and their sum
The solution opens after your first Check.