Answer to Question #292436 in Python for gayathri

Question #292436

given integer n as input.write a program to print the sum of series of 1+11+111+...n terms


1
Expert's answer
2022-01-31T11:28:30-0500
""" Given

N = 4The sum for first

4 terms is 1 + 11 + 111 + 1111So the output should be

1234.

Sample Input 1

4

Sample Output 1

1234

Sample Input 2

5

Sample Output 2

12345 """

# the code is 
n = int(input())


count = 0
line =''


for i in range(n):
    line += "1"
    count += int(line)


print(count)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS