Example #1
0
import functions

divisors = sorted(functions.divisors(600851475143), reverse = True)

for divisor in divisors:
	if functions.is_prime(divisor):
		print(divisor)
		break
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
# A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n.
# As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit.
# Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.
from functions import divisors

liste = []
toplamlar = set()

for n in range(11,28123):
    if(sum(divisors(n))>n):
        liste.append(n)

for p in liste:
    for q in liste:
        if(p+q<28123):
            toplamlar.add(p+q)

sayilar = set(range(1,28123))

print(sum(sayilar-toplamlar))
Example #3
0
import functions

triangle = 3
i = 2
nb_divisors = 0

while nb_divisors < 500:
	i += 1
	triangle += i
	nb_divisors = len(functions.divisors(triangle, True))

print(triangle)
Example #4
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
# If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
# For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
#Evaluate the sum of all the amicable numbers under 10000.

from functions import divisors
toplam=0
for i in range(220,10000):
    if(i!=sum(divisors(i)) and i==sum(divisors(sum(divisors(i))))):
        toplam += i
print(toplam)
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
# If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
# For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
#Evaluate the sum of all the amicable numbers under 10000.

from functions import divisors
toplam = 0
for i in range(220, 10000):
    if (i != sum(divisors(i)) and i == sum(divisors(sum(divisors(i))))):
        toplam += i
print(toplam)
Example #6
0
def d(nb):
	return 1 + sum(functions.divisors(nb))
Example #7
0
from functions import divisors

n, sayi = 1, 1

while(len(divisors(sayi))<500):
    n += 1
    sayi += n

print(sayi)
from functions import divisors


def triangle(n):
    sayi = 0
    for i in range(1, n + 1):
        sayi += i
    return sayi


n = 1
while len(divisors(triangle(n))) < 500:
    n += 1
print(triangle(n))
Example #9
0
from functions import isPandigital, divisors, digits

solution = 0

for n in range(1000, 10000):
    for a in divisors(n):
        b = n / a

        d = digits(a)
        d.extend(digits(b))
        d.extend(digits(n))

        if (len(d) == 9) and isPandigital(d):
            print "{} * {} = {}".format(a, b, n)
            solution += n
            break

print(solution)