Skip to content

Instantly share code, notes, and snippets.

@yotamN
Created October 18, 2015 12:26
Show Gist options
  • Save yotamN/c4e3aeaecd2f96bab7fe to your computer and use it in GitHub Desktop.
Save yotamN/c4e3aeaecd2f96bab7fe to your computer and use it in GitHub Desktop.
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