Original title:
Seeking s = a + aa + aaa + aaaa + aa ... the value of a, where a is a number. E.g. 2 + 22 + 222 + 2222 + 22222 (in this case the sum total of the number 5), the number added by several keyboard.
My code:
# ! / Usr / bin / Python # encoding = UTF. 8- # - * - Coding: UTF-. 8 - * - # find s = a + aa + aaa + aaaa + aa ... the value of a, where a is a digital. E.g. 2 + 22 + 222 + 2222 + 22222 (in this case the sum total of the number 5), the number added by several keyboard. X = int (INPUT ( " Please The INPUT Number X: \ n- " )) # input to 2 shown above problems Y = int (INPUT ( " Please The INPUT Number Y: \ n- " )) # input as title to 5 FIG S1 = 0 S = 0 # for counting all sum; IF X in [1,2,3,4,5,6,7,8,9 ]: IF Y> =. 1 and Y =%. 1 = 0: for i in range(1,y+1): s1 = s1 + x * 10 ** (i-1) s = s + s1 print(s,s1) print("###",s)
Too simple, nothing can be explained;
Original answer questions given relatively simple;
-------- (I am dividing line) --------
reference:
1. RUNOOB.COM:https://www.runoob.com/python/python-exercise-example18.html
Remarks:
Initial modified: October 3, 2019 10:45:49
Environment: Windows 7 / Python 3.7.2