Chapter 2-4 serial number of a particular column summation python

Given no more than two positive integers a and n 9, requiring programming find a + aa + aaa ++ ⋯ + aa ⋯ a (n th a) the sum.

Input format:
input gives no more than 9, and n is a positive integer in a row.

Output format:
in accordance with "s = and corresponding to" format in the output line.

Sample input:
23

Sample Output:
S = 246

a,n=input().split()
n=int(n)
s=sum(int(a*i) for i in range(1,n+1))
print("s = %d"%s)                     #运用字符串的*性质
Published 14 original articles · won praise 1 · views 94

Guess you like

Origin blog.csdn.net/weixin_45948920/article/details/104345466