예제 #1
0
def main():
    start = clock()
    bestLen, bestList = 0, []
    for a in range(-1000, 1001):
        if not isPrime(abs(a)):
            continue
        for b in range(-1000, 1001):
            if not isPrime(abs(b)):
                continue
            abLen = primeLength([a, b])
            if abLen > bestLen:
                bestLen, bestList = abLen, [a, b]

    print "%s found in %s seconds" % (bestList[0] * bestList[1], clock() - start)
예제 #2
0
def isReptend(p):
    '''Return whether the number is a Full Reptend Prime
       Formula: 10 ** k = 1(mod p) for k = p - 1'''
    if not isPrime(p):
        return False

    k = 1
    while (10 ** k) % p != 1:
        k += 1

    if k == p - 1:
        return True
    return False