Skip to content

Instantly share code, notes, and snippets.

@BedirYilmaz
Created October 24, 2016 09:16
Show Gist options
  • Save BedirYilmaz/7558628e0dc19411fba46ea20e52b8a1 to your computer and use it in GitHub Desktop.
Save BedirYilmaz/7558628e0dc19411fba46ea20e52b8a1 to your computer and use it in GitHub Desktop.
Find the value of the first triangle number to have over five hundred divisors?
def numberofdivisors(n):
count = 0
for x in range(1,n+1):
if n%x ==0:
count+=1
return count;
def summer(n):
sum = 0
for x in range(1,n):
sum += x
return sum
a = 0
x = 12300
a = summer(x)
while True:
a += x
nmdiv = numberofdivisors(a)
if(nmdiv>500):
print(str(a) + " has " + str(nmdiv) + " divisors")
break
x+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment