Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a in Python.
Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.
Python Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | digit=int(input("Enter digit:")) num=input("enter a number:") result=0 for i in range(1,digit+1): result= result + int(str(num*i)) print(num*i) print("________________+\n") print(result) |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Enter digit:10 enter a number:2 2 22 222 2222 22222 222222 2222222 22222222 222222222 2222222222 ________________+ 2469135800 |