Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 56 lines (50 sloc) 1.126 kb
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
import math

def is_prime(n):
    if n < 2:
        return False
    for j in range(2, math.sqrt(n) + 1):
        if n%j == 0:
            return False
    return True

def get_factors(n):
    factors = []
    for j in range(2, math.sqrt(n) + 1):
        if n%j == 0:
            factors.append(j)
            factors.append(n/j)
    return factors

def get_prime_factors(n):
    pf = []
    seq = []
    factors = get_factors(n)
    for factor in factors:
        if is_prime(factor):
            pf.append(factor)
    while len(pf):
        prime = pf.pop()
        n /= prime
        seq.append(prime)
    if n > 0:
        if n in seq:
            seq[seq.index(n)] *= 2
    return seq

consecutive = 0
i = 647
found = []

while consecutive < 4:
    i += 1
    factors = get_prime_factors(i)
    if len(factors) == 4:
        unique = True
        for factor in factors:
            if factor in found:
                consecutive = 0
                unique = False
                found = []
                break
    else:
        unique = False
    if unique:
        found += factors
        consecutive += 1

print i
Something went wrong with that request. Please try again.