You are viewing a single comment's thread. Return to all comments →
simple solution in go
func superDigit(n string, k int32) int32 { if len(n) == 1 { return int32(n[0]-'0') } var sd int64 for _, r := range n { sd = sd + int64(r-'0') } return superDigit(fmt.Sprintf("%d", sd * int64(k)), 1) }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
simple solution in go