Powerful digit sum
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100
is almost unimaginably large: one followed by two-hundred zeros.
Despite their size, the sum of the digits in each number is only 1.
Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum?
Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum?
An another problem on sum of digits. Algorithm is very simple. It is as follows:
1) Write a function to find the sum of digits of the given number. The function is as follows:
- Let the number be n.
- Start a while loop. Create a variable to store the sum of numbers.
- Find the remainder of the number when divided by 10. This remainder will be the last digit. Add this number to the sum.
- Divide the number with 10 and go again for step 2, until the number becomes 0.
Have a look at the program directly even if you have not read the algorithm. It is very simple.
Program
You can download the source code from Github Gist pep56.pyOutput
Summary
Not a very tough problem. But I have seen many people on the forum using the range from 90 to 100, which I didn't understand. So I am leaving this one for you. Please comment if you know the reason.Please do correct me if my grammar is wrong or in an ambiguous way.
Comment in the comment box below if you have any doubt or haven't understood anything. I will be glad to help you.
Please comment if you have found any typo or have a better or different program or have a suggestion. I will be very happy to view each of them.
You can also contact me.
Thank you. Have a great day😃!