Advertisement
Guest User

safddasfasddfsadfasdfasdf

a guest
Apr 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. line = input().split()
  2. n = line[0]
  3. k = int(line[1])
  4.  
  5. #removed the whole global superdigit construct, now its just a parameter of calc
  6.  
  7. def calc(superdigit, k): #added k here
  8.    
  9.     superlist = list(str(superdigit))
  10.    
  11.     temp = 0
  12.    
  13.     for i in range(len(superlist)):
  14.         temp = (temp + int(superlist[i]))
  15.  
  16.     temp = temp * k #added this
  17.  
  18.     if (len(str(temp)) > 1):
  19.         calc(temp, 1) #for every recursive step k=1
  20.        
  21.     else: print (temp)
  22.        
  23.        
  24.     return
  25.  
  26. calc(n, k) #we take in n and k directly
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement