def is_truncatable_prime(n):
    if not my_module.is_prime(n):
        return(False)
    for i in xrange(1, len(str(n))):
        if not my_module.is_prime(int(str(n)[:i])):
            return(False)
        if not my_module.is_prime(int(str(n)[i:])):
            return(False)
    return(True)
def get_distinct_prime_factors(n):
    prime_factors = []
    divisors = my_module.get_proper_divisors(n)
    for i in divisors:
        if my_module.is_prime(i):
            prime_factors.append(i)
    return(prime_factors)
def consecutive_primes_from_quadratic(a, b):
    primes = 0
    for i in xrange(0, 100000):
        if ((i ** 2) + (i * a) + b) > 1:
            if my_module.is_prime((i ** 2) + (i * a) + b):
                primes += 1
            else:
                break
    return(primes)
예제 #4
0
def is_list_prime(primelist):
    for i in primelist:
        if not my_module.is_prime(i):
            return(False)
    return(True)
예제 #5
0
def generate_prime(floor, ceiling):
    primes = []
    for i in xrange(floor, ceiling):
        if my_module.is_prime(i):
            primes.append(i)
    return primes
예제 #6
0
import my_module


primesums = []
primesumslen = []
primes = my_module.generate_prime(2, 10000)
for a in xrange(1, len(primes)):
    for b in xrange(1, len(primes)):
        if sum(primes[a:][:-b]) < 1000000:
            if my_module.is_prime(sum(primes[a:][:-b])):
                primesums.append(sum(primes[a:][:-b]))
                primesumslen.append(len(primes[a:][:-b]))
print(primesums[primesumslen.index(max(primesumslen))])
예제 #7
0
 def test_is_prime(self):
     self.assertFalse(my_module.is_prime(1))
     self.assertTrue(my_module.is_prime(2))
     self.assertTrue(my_module.is_prime(193))
     self.assertFalse(my_module.is_prime(49))
예제 #8
0
import my_module


for i in xrange(2, 5800):
    if i % 2 == 1:
        if not my_module.is_prime(i):
            if not my_module.is_goldback_composite(i):
                print(i)
예제 #9
0
import my_module
import itertools


permutations = itertools.permutations('1234567', 7)
intpermutations = [int("".join(i)) for i in permutations]
primes = []
for n in intpermutations:
    if my_module.is_prime(n):
        primes.append(n)
print(max(primes))
예제 #10
0
        families.append(family)
    return(families)

def getfamilymembers(n):
    families = getfamilies(n)
    familymembers = []
    for i in families:
        family = []
        for x in range(1, 10):
            member = []
            for digit in i:
                if digit == "*":
                    member.append(str(x))
                else:
                    member.append(digit)
            family.append("".join(member))
        familymembers.append(family)
    return(familymembers)

primes = (my_module.generate_prime(10, 130000))

for i in primes:
    for family in getfamilymembers(str(i)):
        count = 0
        for n in family:
            if my_module.is_prime(int(n)):
                count += 1
        if count == 8:
            print(min(family))
            sys.exit()
예제 #11
0
def is_circular_prime(n):
    if my_module.is_prime(n):
        rotations = my_module.get_rotations(n)
        if my_module.is_list_prime(rotations):
            return(True)
    return(False)