We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
According to the problem we can say the initial number has at most 10^5 digits. So the initial sum (not considering the repetition time should be at most 9 * 10^5 which can be stored in an 'int' variable. But the problem only can be solved when using 'long' for the sum variable.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
According to the problem we can say the initial number has at most 10^5 digits. So the initial sum (not considering the repetition time should be at most 9 * 10^5 which can be stored in an 'int' variable. But the problem only can be solved when using 'long' for the sum variable.