Пример #1
0
def fl(n):
    digits = list(str(n))
    while len(digits) > 1:
        digits = digits[1:]
        number = int(eulersupport.list_to_str(digits))
        if not eulermath.PrimesHelper().is_prime(number):
            return False
    return True
Пример #2
0
def run():
    result = 0;

    for i in eulermath.permutations(list("1234567890")):
        str_i = eulersupport.list_to_str(i);
        int_i = int(str_i);
        if(eulermath.is_strictly_pandigital(int_i, 0, 9) and f(int_i)):
            print str_i;
            result += 1;

    eulersupport.write_output(result);
Пример #3
0
def run():
    result = 0

    for i in eulermath.permutations(list("1234567890")):
        str_i = eulersupport.list_to_str(i)
        int_i = int(str_i)
        if (eulermath.is_strictly_pandigital(int_i, 0, 9) and f(int_i)):
            print str_i
            result += 1

    eulersupport.write_output(result)
Пример #4
0
def run(upperbound):
    list_of_primes = [];

    #Find all the primes.
    eulermath.PrimesHelper().find_all_primes_up_to_n(upperbound);
    for prime in eulermath.PrimesHelper().get_primes():
        digits = list(str(prime));

        #Check if all permutations are prime.
        perms = eulermath.all_rotations(digits);
        perms = [int(eulersupport.list_to_str(perm)) for perm in perms];

        all_perms_are_prime = all(eulermath.PrimesHelper().is_prime(x) for x in perms);
        print prime, "-", perms, all_perms_are_prime;

        #Add to list of primes
        if(all_perms_are_prime):
            list_of_primes.append(prime);

    eulersupport.write_output(len(list_of_primes));
Пример #5
0
def run(upperbound):
    list_of_primes = []

    #Find all the primes.
    eulermath.PrimesHelper().find_all_primes_up_to_n(upperbound)
    for prime in eulermath.PrimesHelper().get_primes():
        digits = list(str(prime))

        #Check if all permutations are prime.
        perms = eulermath.all_rotations(digits)
        perms = [int(eulersupport.list_to_str(perm)) for perm in perms]

        all_perms_are_prime = all(eulermath.PrimesHelper().is_prime(x)
                                  for x in perms)
        print prime, "-", perms, all_perms_are_prime

        #Add to list of primes
        if (all_perms_are_prime):
            list_of_primes.append(prime)

    eulersupport.write_output(len(list_of_primes))
Пример #6
0
def run(seq, upperbound):
    print seq, upperbound
    result = eulermath.permutation_at_index(seq, upperbound)
    result = eulersupport.list_to_str(result)
    #Report Completion.
    eulersupport.write_output(result)
Пример #7
0
def run(seq, upperbound):
    print seq, upperbound;
    result = eulermath.permutation_at_index(seq, upperbound);
    result = eulersupport.list_to_str(result);
    #Report Completion.
    eulersupport.write_output(result);