-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem056.m
More file actions
23 lines (23 loc) · 797 Bytes
/
problem056.m
File metadata and controls
23 lines (23 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function s = problem056()
%A googol (10^(100)) is a massive number: one followed by one-hundred zeros;
%100^(100) is almost unimaginably large: one followed by two-hundred zeros.
%Despite their size, the sum of the digits in each number is only 1.
%Considering natural numbers of the form, a^(b), where a, b < 100, what is the maximum digital sum?
%The function digital_mul.m should be defined in the directory
s = 0; % for storing the sum of digits in the number
for i = 99:-1:80
for j = 99:-1:80
%The number is of the form i^j
k = 0;t = [1];
while k < j
t = digital_mul(t,i);
s1 = sum(t);
k = k +1;
end
if s < s1
s = s1;
I = i;
J = j;
end
end
end