Beispiel #1
0
def get_primes(number):
    """
    return prime number in order
    """
    while True:
        if is_prime(number):
            yield number
        number += 1
Beispiel #2
0
def consecutive_solutions(aaa, bbb):
    """Return the number of consective primes
    given by n**2 + a*n + b for *aaa* and *bbb* starting from
    n = 0.
    """
    num = 0
    while is_prime(num**2 + aaa*num + bbb):
        num += 1
    return num - 2  # -2 accounts for 0 and extra n += 1 in while loop.
Beispiel #3
0
"""
solve project euler problem 49
"""
from prime_factorisation import is_prime


def characters(string):
    """
    return characters in a string
    """
    return sorted(list(str(string)))

for a in xrange(1000, 10000):
    for b in xrange(1, (10000-a)/2+1):
        if (is_prime(a) and is_prime(a+b) and is_prime(a+b+b) and
                characters(a) == characters(a+b) == characters(a+b+b)):
            print a, a+b, a+b+b
 def test_is_prime(self):
     """unittest prime_factorisation.is_prime()"""
     self.assertTrue(prime_factorisation.is_prime(997))
Beispiel #5
0
def main():
    inum = 2
    while (goldbachs_other_conjecture(inum) or is_prime(inum) or
           inum % 2 == 0):
        inum += 1
    print inum