Beispiel #1
0
def check_circular_prime(num):
    if not isprime(num):
        return False
    rotated = rotate_once(num)
    while not rotated == str(num):
        if not isprime(int(rotated)):
            return False
        rotated = rotate_once(rotated)
    return True
Beispiel #2
0
def check_circular_prime(num):
	if not isprime(num):
		return False
	rotated = rotate_once(num)
	while not rotated == str(num):
		if not isprime(int(rotated)):
			return False
		rotated = rotate_once(rotated)
	return True
Beispiel #3
0
Datei: p60.py Projekt: bwo/euler
def testconcat(p,q):
    p, q = primes[p], primes[q]
    if (p,q) in memo: return memo[(p,q)]
    if not isprime((10**int(1+log10(p)))*q+p, primes) or \
        not isprime((10**int(1+log10(q)))*p+q, primes):
        r = False
    else:
        r = True
    memo[(p,q)] = r
    return r
Beispiel #4
0
Datei: p41.py Projekt: bwo/euler
def main():
    for i in range(9, 2, -1):
        digits = range(i,0,-1)
        pandigitals = permute(tuple(digits))
        for p in pandigitals:
            if p[-1] % 2 == 0: continue
            t = tonum(p)
            if isprime(t, primes):
                print t
                return
Beispiel #5
0
def problem():
	maxn = 0
	for a in xrange(-1000, 1000):
			for b in xrange(-1000, 1000):
				n = 0

				while et.isprime(my_function(n, a, b)):
					n += 1
				if n > maxn:
					maxn = n
					answer = [a,b,n-1]

	return answer[0] * answer[1]
Beispiel #6
0
from eulertools import prime_list_numbers, isprime

primes = prime_list_numbers(1000000)
sums = []

record = (0, 0, 0)

for i in xrange(0, len(primes)):
    count = 1
    while count + i < len(primes):
        x = sum(primes[i:count])
        if x < 1000000:
            if isprime(x):
                if len(primes[i:count]) > record[1]:
                    record = (x , len(primes[i:count]))
                    print record
        count += 1
print record
Beispiel #7
0
from eulertools import isprime

record = 0
keys = (0, 0)
for a in xrange(-999, 1001, 2):
    for b in xrange(-999, 1001, 2):
        n = 0
        while isprime(abs(n**2 + a * n + b)):
            n += 1
        if n > record:
            print "New record %d consecutive primes, keys %d and %d" % (n, a,
                                                                        b)
            record = n
            keys = (a, b)
print record, keys
print keys[0] * keys[1]
Beispiel #8
0
from eulertools import isprime

record = 0
keys = (0, 0)
for a in xrange(-999, 1001, 2):
	for b in xrange(-999, 1001, 2):
		n = 0
		while isprime(abs(n**2 + a * n + b)):
			n += 1
		if n > record:
			print "New record %d consecutive primes, keys %d and %d" % (n, a, b)
			record = n
			keys = (a, b)
print record, keys
print keys[0] * keys[1]