-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp056.py
More file actions
executable file
·29 lines (23 loc) · 777 Bytes
/
p056.py
File metadata and controls
executable file
·29 lines (23 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#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?
import logging
def SumDigits(n):
s = 0
while (n):
s += n % 10
n = n//10
return s
def main(args):
max_sum = 0
max_ab = ()
for a in range(2,100):
if (a % 10 == 0): continue
p = a
for b in range(1,98):
sd = SumDigits(p)
if (sd > max_sum):
max_sum = sd
max_ab = (a, b)
p = p*a
logging.info((max_sum, max_ab))