Created
October 18, 2015 12:26
-
-
Save yotamN/c4e3aeaecd2f96bab7fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int digitSum(int num); | |
int main(void) | |
{ | |
digitSum(345); // 12 | |
return 0; | |
} | |
int digitSum(int num) | |
{ | |
if(num / 10 == 0) | |
return num; | |
return (num % 10) + digitSum(num / 10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment