Created
October 20, 2019 07:24
-
-
Save trhgquan/be61313b440caba8be896ba4c2446922 to your computer and use it in GitHub Desktop.
For more algorithm, visit https://github.com/trhgquan/CPP
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
int root(int n) { | |
if (n >= 10) { | |
int s = 0; | |
while (n > 0) { | |
s += n % 10; | |
n /= 10; | |
} | |
return root(s); | |
} | |
return n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment