Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone please help me with this PYTHON problem! please answer with code! th

ID: 3851623 • Letter: C

Question

Can someone please help me with this PYTHON problem! please answer with code! the only parts that you need to change have # YOUR CODE HERE

The Super Digit¶

The "super digit" of a (base 10) number N is defined as follows:

if the number consists of a single digit, it is simply N

otherwise, it is the super digit of the sum of the digits of N

Examples:

the super digit of 7 is 7

the super digit of 42 is the super digit of 4+2=6, which is 6

the super digit of 9876 is the super digit of 9+8+7+6=30, which is the super digit of 3+0=3, which is 3

Implement the recursive function super_digit, which returns the super digit of its argument.

In [ ]:

. . .

In [ ]:

Explanation / Answer

Replace YOUR CODE with the code given below and it works.

Logic : Take the sum of the digits of a number recursively till the sum become a single digit.

def super_digit(n):
  
   if n < 10:
       return n
  
   sum = 0
  
   while n != 0:
       sum = sum + n%10
       n = n//10
   return super_digit(sum)