Example : If my input is 582109 , the output should be (5+8+2+1+0+9)+(8+2+1+0+9)+(2+1+0+9)+(1+0+9)+(0+9)+(9)=25+20+12+10+9+9=85
Code:
def getSum(n):
sum = 0
while (n != 0):
sum = sum + int(n % 10)
n = int(n/10)
return sum
n = int(input("Number : "))
print(getSum(n))
This code is just giving sum of all digits in input. how to make it calculate the sum of sum of digits in cyclic order as mentioned in example?