# Welcome to 100th Daily Challenge

Thanks @peter for starting this and thanks to all those who participated either as making challenges or solving them . Also a big shout-out again to @peter for the above artwork

# The Challenge

### Sum of Digits :

The challenge is to Kode procedure for finding the sum of digits of a given number until the sum we get is a single digit.

# Input

A n digit non-negative number

# Output

A single digit integer

# Sample Set

``````1. 24 => 2 + 4 => 6
2. 356 => 3 + 5 + 6 => 14 => 1 + 4 => 5
3. 123 => 1 + 2 + 3 => 6
4. 42654 => 21 => 2 + 1 => 3
5. 34.08 => 15 => 1 + 5 => 6
``````

# Winner

There will be two winners of this challenge as:

# Explanation:

All the Best

5 Likes

Here’s mine

Solution (24 blocks)
2 Likes

that was quick

1 Like

Just now one little bug in my blocks crashes my whole phone
Now it’s alright.

1 Like

Solution (11 blocks)

Explanation

Solving the Digital Root Algorithm using JavaScript - DEV

5 Likes

smart one but what about in case of decimal ?

1 Like

It doesn’t work

Btw, are you able to see the solution?

1 Like

yes,i saw, input can be any non negative number

Caught!

3 Likes

technically still your solution do not reach challenge requirement. just a small change

# Fixed

Solution (14 blocks)

5 Likes

Be carefull from now! every thing you think is already thought by me , now there are no secrets of Kodular

4 Likes

Here is my Try
Disclaimer: I knew the fact that the digital root of multiples of 9 is always 9 but never thought of using it for other numbers until I saw @pavi2410 post. So basically credits go to her.

12 Blocks

10 Blocks

(Improper Method): uses RHS limit of 9 which is not possible to write perfectly, so it works for the limited number of digits that can be anything 50, 100, 10000 anything but not for infinite digits. However, if we stretch 9.0000…goeson…0001 to the max limit of computation then it works the same as the above code.

4 Likes

Her

2 Likes

different result coming when calling procedure and if manually running the code inside procedure?
input: 99999999999999999999999999999999907979

1 Like

do u have any idea of this behaviour ?

Absolutely no idea.
Interesting
@Deepanshu_Arya can you check that data passed to the procedure is same as that of data in callProcedure method. Maybe due to large number of digits it is passing only first few digits.

1 Like

For those who are wondering what is the right answer for digital sum of 99999999999999999999999999999999907979

It is 5

Maybe there is some problem in calling procedure method

1 Like

Issue solved:

need to pass number as a string. Dont know why but if the it is passed as number it change the number to some another number

1 Like

i am really curious about this behaviour of procedure. It will be interesting to know why this happens.

You were wrong boi