Community

Start a Thread


Notifications
Subscribe You’re not receiving notifications from this thread.

Sum until one digit

Challenges • Asked over 3 years ago by orlandu8@gmail.com

orlandu8@gmail.com Commented on Jul 15, 2021:

Here's what I got for the solution

function sumDigits(num) {
let n = num % 9;
if(n === 0) {
return 9;
} else {
return n;
}
}

The challenge says expected time complexity to be O(log n), but unless I'm missing something here. This is O(1) isn't it?