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

39
projecteuler/012/main.py Normal file
View File

@@ -0,0 +1,39 @@
import os
import math
import numpy as np
# Triangle numbers are simply the sum of all natural numbers.
# Then, find the first triangle number that has over five hundred divisors.
def getTriangle(n):
# return sum(range(1, n + 1))
# Instead just use the formula like any normal human being
return int(n * (n+1) / 2)
def getTriangles(n):
return [getTriangle(x) for x in range(1, n + 1)]
def getNumberOfDivs(n):
# Fuck this function
def main():
print("Hello, this is Patrick")
ts = getTriangles(7)
print(ts)
for t in ts:
print(getNumberOfDivs(t))
if __name__ == "__main__":
main()