Last active
September 26, 2018 16:23
-
-
Save belushkin/d99cfabc51953b980a81641f2be4a0f5 to your computer and use it in GitHub Desktop.
sum Digits
This file contains 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
<?php | |
function sumDigits($n) | |
{ | |
return ($n == 0) ? 0 : $n%10 + sumDigits($n/10); | |
} | |
// Driver Code | |
$n = 687; | |
$res = sumDigits($n); | |
echo("$res"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment