Rebased projecteuler folder, now includes all contest programming stuff

This commit is contained in:
2021-10-26 10:54:24 +02:00
parent 1aa6120838
commit e0c627a384
77 changed files with 203 additions and 67 deletions

37
projecteuler/056/main.py Normal file
View File

@@ -0,0 +1,37 @@
'''
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 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, ab, where a, b < 100, what is the maximum digital sum?
'''
import time
import math
def intSum(n):
res = 0
while n > 0:
res += n % 10
n //= 10
return res
def main():
print("Hello, this is Patrick")
t0 = time.time()
maxSum = 0
for a in range(100):
if a % 10 == 0:
continue
for b in range(100):
if b % 10 == 0:
continue
if intSum(a**b) > maxSum:
maxSum = intSum(a**b)
print(maxSum, time.time() - t0)
if __name__ == "__main__":
main()