6. Write a Python program that reads a number and finds the sum of the series of 1 +11 + 111 + 1111 + ….+N terms.
=====================================================
Sample Input1:
5
Sample Output1:
1 + 11 + 111 + 1111 + 11111
The Sum is: 1234
n = int(input("Enter number N: "))
print()
sum = 0
str = ''
for i in range(n):
str = str + '1'
sum = sum + int(str)
print(f'Sum: {sum}')
Comments
Leave a comment