Project Euler/12

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Project Euler Problem 12 is a problem related to triangular numbers. The task is to find the smallest triangular number with over 500 divisors.

Implementations

Python

from math import *
def divisors(x):
    r=0
    for i in range(1,int(sqrt(x))+1):
        if x%i==0:
            if i*i==x:
                r+=1
            else:
                r+=2
    return r
x=1
while divisors(x*(x+1)//2)<=500:
    x+=1
print(x*(x+1)//2)

External resources