Answer to Question #222431 in Python for srikanth

Question #222431
Sum of 1 series

Given integer 

N as input. Write a program to print the sum of series 1 + 11 + 111 + .... N terms.

Input

The first line of input is an integer N.

Output

The output should be an integer representing the sum of series.

Explanation

Given 

N = 4

The sum for first 

4 terms is 1 + 11 + 111 + 1111

So the output should be 

1234.

Sample Input 1
4
Sample Output 1
1234
Sample Input 2
5
Sample Output 2
12345

sample input 3
10
sample output3
1234567900
1
Expert's answer
2021-08-02T07:12:16-0400
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