-
2 Comments
晧瑜戴on 30 Apr 2020
function b = sumDigits(n)
pow=2^n;
b = 0;
while pow~=0
b=b+mod(pow,10);
pow=floor(pow/10);
end
end
Syed Shahedon 2 May 2020
The code is wrong. Cause the while doest have a stopping condition.
Suggested Problems
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
1144 Solvers
304 Solvers
442 Solvers
Matlab Basics - y as a function of x
408 Solvers
2720 Solvers
More from this Author95
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!