+ 4
Code challenge question
here is a code challenge question for all coders in Sololearn. write a function that takes integer input and return the sum of all digits of the number. public int digit_sum(int num) { //this is for you to fill } digit_sum(1042) must return 7.
11 Answers
+ 8
https://code.sololearn.com/WvjnyPF3L8iY/?ref=app
As basic as I could make it.
+ 7
simple js approach
https://code.sololearn.com/Wxsc5VbO2zOA/?ref=app
+ 6
Made one in PHP too:
https://code.sololearn.com/wAi62g12SQ11/?ref=app
+ 5
The best I could come up with: https://code.sololearn.com/cuDPXza20h71/?ref=app
+ 5
Here's my answer
https://code.sololearn.com/cTgjPovJzU8P/?ref=app
+ 4
Oh, I just saw this was a general question, not C++ specific, anyway at least I got a bit more familiar with C++ type conversion, brb with a C# version.
+ 3
yes it is open for any language
+ 2
all are awesome!