@AmeliaBlackwell/

MessyEagerPlanes

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def tri(n):
    return int(0.5*n*n+0.5*n)

def div(u):
    x=1
    divs=[]
    dn=0
    while x<=0.5*u:
        if u%x==0:
            divs.append(x)
            dn+=1
        x+=1
    divs.append(u)
    dn+=1
    return dn,divs
    

#print([tri(n) for n in range(1,20)])

def find(f):
    flag=False
    n=1
    while not flag:
        dn,divs=div(tri(n))
        if dn>f:
            print("{0} has {1} divisors: {2}".format(str(tri(n)),str(dn),", ".join([str(div) for div in divs])))
            flag=True
        n+=1

def show(l):
    n=1
    while n<=l:
        dn,divs=div(tri(n))
        print("{0} has {1} divisors: {2}".format(str(tri(n)),str(dn),", ".join([str(div) for div in divs])))
        n+=1

#show(100)
show(50)