Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Which language? Which test, and what's the input parameter (print it)? Please provide more insight before marking as an issue.
In the Java testcases, the expected and the actual are swapped around, so your solution is returning 15 and the expected answer is 6.
Instructions are very clear.
The description states:
recusive = characterized by recurrence or repetition
This implies your code has to keep repeating. Unless you're fucking retarded you should know the sum of digits of a single digit is the digit itself and therefore your code should stop.
This description also provides valid examples, for example:
Read the comments next time you think you encounter an issue.
Your code only calculates the sum of digits once, but you need to keep summing the digits of the new number if the number is less than 10. Read the description, it states that the function is recursive, so you have to keep doing it until there is only one digit. The input value is 195, the expected value is 6 and your code returns 15.
Read the comments next time you think you encounter an issue.
Your code only calculates the sum of digits once, but you need to keep summing the digits of the new number if the number is less than 10. Read the description, it states that the function is recursive, so you have to keep doing it until there is only one digit. The input value is 195, the expected value is 6 and your code returns 15.
Happy to be told that I am wrong, but this did not work for me:
n.to_s.split("").inject(0) { |res, num| res += num.to_i }
I think jriches is right, there might be a problem with the tests.