[python practice questions] program 18

#Question : Find the value of s=a+aa+aaa+aaaa+aa...a, where a is a number. For example, 2+22+222+2222+22222 (5 numbers are added at this time), and the addition of several numbers is controlled by the keyboard. 

x = input( ' Enter a number: ' )
y = input( ' input number: ' )

def zonghe(x,y):

    y = int(y)
    s = 0
    for i in range(1,y+1):
        #print(int(x*i))
        s += int(x*i)
    print (s)

zonghe(x,y)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325075863&siteId=291194637