예제 #1
0
파일: problem35.py 프로젝트: bhuber/pyler
def problem35(n):
    cps = set()
    first_n_primes = set()
    for p in PrimeGenerators.primes_less_than(n):
        first_n_primes.add(p)

    def check_circular(p):
        if p in cps:
            return
        sp = str(p)
        length = len(sp)
        digits = [int(i) for i in sp]
        cycles = []
        for i in xrange(0, length):
            t = combine_digits(digits)
            if not t in first_n_primes:
                return
            cycles.append(t)
            digits = rotate_left(digits)

        cps.update(cycles)

    for p in first_n_primes:
        check_circular(p)

    return cps
예제 #2
0
파일: problem7.py 프로젝트: bhuber/pyler
def problem7(n):
    result = 0
    for p in PrimeGenerators.first_n_primes(n):
        result = p

    return result
예제 #3
0
파일: problem10.py 프로젝트: bhuber/pyler
def problem10(n):
    return sum(PrimeGenerators.primes_less_than(n))