Esempio n. 1
0
"""This is Problem 21 of Project Euler

Find the sum of all amicable numbers under 10000

An amicable pair is define as m,n such that the proper divisors of m sum 
to n and the proper divisors of n sum to m"""

__author__ = "Andrew Phoenix"

import eulib
top = 10000
x = 1
divisorsum = [0]
while x < top:
    g = sum(eulib.divisors(x)) - x
    divisorsum.append(g)
    x = x + 1
answer = 0
for i in range(top):
    print i, divisorsum[i]
    if divisorsum[i] < top:
        print 'what ' + str(divisorsum[divisorsum[i]])
        if divisorsum[divisorsum[i]] < top:
            if divisorsum[i] != i:
                if divisorsum[divisorsum[i]] == i:
                    answer = answer + i
print 'the answer is ' + str(answer)
Esempio n. 2
0
""" This is Problem 12 of Project Euler.

What is the first triangle number to have over 500 divisors?

Note that the first number to have 500 divisors is 62370000.
The first Triangle number that is bigger than that is the 11169th triangle number: 62378865

"""

__author__ = "Andrew Phoenix"

import eulib
'''the first number with 500 divisors is 62370000 a triangular number near there is tri(3531)'''

x = 3531

while len(eulib.divisors(eulib.gentri(x))) < 500:
    x = x + 1
print eulib.gentri(x)
Esempio n. 3
0
"""This is Problem 21 of Project Euler

Find the sum of all amicable numbers under 10000

An amicable pair is define as m,n such that the proper divisors of m sum 
to n and the proper divisors of n sum to m"""

__author__ ="Andrew Phoenix"

import eulib
top=10000
x=1
divisorsum = [0]
while x < top:
    g=sum(eulib.divisors(x))-x
    divisorsum.append(g)
    x = x + 1
answer=0
for i in range(top):
    print i, divisorsum[i]
    if divisorsum[i] < top:
        print 'what ' + str(divisorsum[divisorsum[i]])
        if divisorsum[divisorsum[i]] < top:
            if divisorsum[i] != i:
                if divisorsum[divisorsum[i]] == i:
                    answer = answer + i
print 'the answer is ' + str(answer)
Esempio n. 4
0
""" This is Problem 12 of Project Euler.

What is the first triangle number to have over 500 divisors?

Note that the first number to have 500 divisors is 62370000.
The first Triangle number that is bigger than that is the 11169th triangle number: 62378865

"""

__author__ = "Andrew Phoenix"

import eulib

'''the first number with 500 divisors is 62370000 a triangular number near there is tri(3531)'''

x=3531

while len(eulib.divisors(eulib.gentri(x)))<500:
    x=x+1
print eulib.gentri(x)