2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^N?
Thanks to Project Euler Problem 16.
added a test case to make it a wee bit harder
function y = pow2_sumofdigits(x)
number = sym(2^x);
n = char(number);
y = 0;
for i = 1:length(n)
y = y + str2double(n(i));
this code gives exact results on my mechine but not work in cody show error
Error: License checkout failed.
License Manager Error -5
Cannot find a license for Symbolic_Toolbox.
Troubleshoot this issue by visiting:
License path: email@example.com:firstname.lastname@example.org:/tmp/matlabpref/.matlab/R2013a_licenses:/opt/mlsedu/matlab/R2013a/licenses/license.dat:/opt/mlsedu/matlab/R2013a/licenses
Licensing error: -5,0.
please help me ...........
Determine whether a vector is monotonically increasing
surface of a spherical planet
Make one big string out of two smaller strings
Relative ratio of "1" in binary number
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
Multiples of a Number in a Given Range
Return the 'Size' of a String of Code
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office