Ad
Code
Diff
  • def digital_root(n):
        while n > 9:
            n = sum([int(i) for i in str(n)])
        return n
    • def digital_root(n):
    • while n > 9:
    • sum = 0
    • while n != 0:
    • sum += n % 10
    • n //= 10
    • n = sum
    • n = sum([int(i) for i in str(n)])
    • return n
Code
Diff
  • def digital_root(n):
        while n > 9:
            sum = 0
            while n != 0:
                sum += n % 10
                n //= 10
            n = sum
        return n
    • def digital_root(n):
    • "NOPE"
    • while n > 9:
    • sum = 0
    • while n != 0:
    • sum += n % 10
    • n //= 10
    • n = sum
    • return n