In a challenge i have to find the sum of digits of one number, like: n = 123 the result should be 1 + 2 + 3 = 6 and if i pass a k to the function, the n should be the concatanation de n * k, like: n = 132, k = 3, n = n * k (123123123), and result should be: 1 + 2 + 3 + 1 + 2 + 3 + 1 + 2 + 3.
some of research i think to use is this function:
sum = 0
while x > 0:
rest = n % 10
n = n // 10
sum = sum + rest
but i think there is a better way to do that. U guys please can help me, please. Thanks :)