Problem 20. Summing digits
Given n, find the sum of the digits that make up 2^n.
Example:
Input n = 7 Output b = 11
since 2^7 = 128, and 1 + 2 + 8 = 11..
Solution Stats
Problem Comments
-
6 Comments
Show
3 older comments
Majid Farzaneh
on 17 May 2018
Good
Syed Shahed
on 2 May 2020
The test case 3 is totally wrong. It needs immediate correction. The code maker didn't notice that b=25 is a number not a single digit. If you're doing the sum of digits it always ends up with a single digit, it will never end up with number cause number itself is carrying multiple digits.
AMAR GAIKWAD
on 26 Jun 2020
Just for the badge ; )
Solution Comments
Show commentsProblem Recent Solvers7725
Suggested Problems
-
Calculate the Levenshtein distance between two strings
1453 Solvers
-
Number of 1s in a binary string
9606 Solvers
-
Relative ratio of "1" in binary number
1455 Solvers
-
604 Solvers
-
Number of Even Elements in Fibonacci Sequence
1431 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!