We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defcombineMethod(n,k):returnstr(n)*kdefsumCurrentDigit(current):sum=0forrecordincurrent:sum+=int(record)returnsumdefgetSuperDigit(combineDigit):super=Nonecurrent=list(str(combineDigit))while(True):iflen(current)==1:super=currentbreaksumDg=sumCurrentDigit(current)current=list(str(sumDg))returnsuperdefsuperDigit(n,k):# Write your code heresumCurrent=sumCurrentDigit(n)combineDigit=combineMethod(sumCurrent,k)super=getSuperDigit(combineDigit)super=super[0]super=int(super)returnsuper
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
you need to sum first before combine the string
very manual way in python