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

26
projecteuler/030/main.py Normal file
View File

@@ -0,0 +1,26 @@
# Digit fifth powers
# 1634, 8208 and 9474 are the only number that can be written as the sum of the fourth powers of their digits
# Find the sum of all the numbers that can be written as the sum of the fifth powers of their digits
# Through some googling, we found an upper bound of the result at 6*9^5 = 354294
# So, we can just bruteforce it, not that big of a search space
def intToList(n):
return [int(d) for d in str(n)]
def sumIntPowers(n, p=5):
return sum([d**p for d in intToList(n)])
def main():
print("Hello, this is Patrick")
result = 0
for n in range(10, 999999):
if n == sumIntPowers(n):
result += n
print(result)
if __name__ == "__main__":
main()