Problem 43019. Iterative sum of digits of 2^n number
Given n, calculate the number 2^n (where n>=0) and iterate until the sum of the digits is a single-digit number.
Example:
Input n = 7
Output sum = 2
because 2^7 = 128, and 1+2+8=11 and 1+1=2.
Solution Stats
Problem Comments
-
7 Comments
Show
4 older comments
ChrisR
on 12 Jul 2021
The test with n = 111 is still incorrect.
Ramon Villamangca
on 27 Oct 2021
is should be 8 for n = 111. am I missing something?
goc3
on 12 Apr 2022
The last test case has been fixed.
Solution Comments
Show commentsProblem Recent Solvers30
Suggested Problems
-
Sort a list of complex numbers based on far they are from the origin.
5689 Solvers
-
Back to basics 21 - Matrix replicating
1605 Solvers
-
Magic is simple (for beginners)
9613 Solvers
-
Find out missing number from a vector of 9 elements
301 Solvers
-
What is Sum Of all elements of Matrix
418 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!