Problem 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 1000 ? Solve this problem using Matlab? Solution This problem is very simple. I suggest you first go through the program and if you cannot understand any part then please go through the explanation section and if you still cannot understand then once go through the links below: 1) tic, toe 2) sym function 3) char function 4) for loop in Matlab 5) str2num function in Matlab 6) disp in Matlab Program tic; y = sym( 2 ^ 1000 ); y = char(y); sum = 0 ; for i = 1 : length (y) sum = sum + str2num(y( i )); end disp (sum); toc; You can download the above program from here: problem_16.m Explanation First I have converted the value of 2 100 as a sym using the symbolic toolbox , because if I log the value, then the value of the output is rounded off and an approximate value is given and not a exact value. Next I have converted the value
With Radius of Circle, people can learn to program and have hands-on tutorials with python and Matlab. ProjectEuler problems solutions are also available to have a better solution and improve the knowledge of people. A lot of algorithms which form the basic programming are also available. I hope the internet community will make use of this blog.