def problem47():
    n, count = 6882, 0#2*3*31*37
    while count != 4:
	primeFactors = prime.primeFactors(n, primes)
	if len(primeFactors)==4:
	    count = count+1
	else:
	    count=0
	n=n+1
    return n-4
Beispiel #2
0
def smallestMultiple(x):
	allFactors = []
	for i in range(2,x):
		factors = prime.primeFactors(i)
		factorSet = list(set(allFactors+factors))
		newSet = []
		for factor in factorSet:
			newSet += [factor] * max(factors.count(factor),allFactors.count(factor))
		allFactors = newSet
	return allFactors
Beispiel #3
0
def phi(n):
    assert n > 0
    if n != 1:
        answer = n
        pFactors = prime.primeFactors(n)
        pFactors = set(pFactors)
        for p in pFactors:
            answer *= 1 - 1.0/p
        return answer
    return 1
Beispiel #4
0
def p47():
    """
     Keep a running count of the number of factors, wait until 4 in a row with
     4 factors are found
     """

    prime = gen_primes()
    primes = [next(prime)]
    i = 2
    count = 0
    while True:
        if (primes[-1] < i):
            primes.append(next(prime))
        if (len(primeFactors(i, primes)) == 4):
            count += 1
        else:
            count = 0
        if (count == 4):
            print(i - 3)
            break
        i += 1
    return
import prime

def fourDistinct(ls):
    if len(ls) == 4:
        return True
    else: return False

primes = []
pFlags = prime.sieveAndSet(10000,primes)

consec = 0

for n in range(1000000):
    factors = prime.primeFactors(n,primes)[0]
    if fourDistinct(factors):
        consec += 1
    else:
        consec = 0

    if consec == 4:
        print(n-3)
import prime


def fourDistinct(ls):
    if len(ls) == 4:
        return True
    else:
        return False


primes = []
pFlags = prime.sieveAndSet(10000, primes)

consec = 0

for n in range(1000000):
    factors = prime.primeFactors(n, primes)[0]
    if fourDistinct(factors):
        consec += 1
    else:
        consec = 0

    if consec == 4:
        print(n - 3)
Beispiel #7
0
def distPrimes(x):
    return len(list(set(prime.primeFactors(x))))
Beispiel #8
0
def isSquareFree(n):
    factors = prime.primeFactors(n)
    return len(factors) == len(set(factors))
Beispiel #9
0
def distPrimes(x):
	return len(list(set(prime.primeFactors(x))))