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.
- Recursive Digit Sum
- Discussions
Recursive Digit Sum
Recursive Digit Sum
Sort by
recency
|
528 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
#
Complete the 'superDigit' function below.
#
The function is expected to return an INTEGER.
The function accepts following parameters:
1. STRING n
2. INTEGER k
#
def superDigit(n, k): total=0 for i in n: total += int(i) if(len(str(total)) > 1): return superDigit(str(total),len(str(total))) else: return total # Write your code here
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
Java solution
solution in few lines using javascript :)
A solution using Python:
I hope it can help, my solution using Go :