Ejemplo n.º 1
0
#===============================================================================
# What is the largest n-digit pandigital prime that exists?
#===============================================================================

from Common import primeSieve, isPandigital

print(max([i for i in primeSieve(10000000) if isPandigital(i)]))
Ejemplo n.º 2
0
# ===============================================================================
# What is the largest n-digit pandigital prime that exists?
# ===============================================================================

from Common import primeSieve, isPandigital

print(max([i for i in primeSieve(10000000) if isPandigital(i)]))
Ejemplo n.º 3
0
# ===============================================================================
# What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n > 1?
# ===============================================================================

from Common import isPandigital


def repeatsDigits(n):
    s = str(n)
    for d in s:
        s = s.replace(d, "", 1)
        if d in s:
            return True
    return False


i = 9999
while True:
    s = ""
    k = 1
    while True:
        s = s + str(i * k)
        if repeatsDigits(s) or int(s) > 987654321:
            break
        elif isPandigital(s):
            print(s)
            exit()
        k += 1
    i -= 1
Ejemplo n.º 4
0
#===============================================================================
# What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n > 1?
#===============================================================================

from Common import isPandigital


def repeatsDigits(n):
    s = str(n)
    for d in s:
        s = s.replace(d, '', 1)
        if d in s:
            return True
    return False


i = 9999
while True:
    s = ''
    k = 1
    while True:
        s = s + str(i * k)
        if repeatsDigits(s) or int(s) > 987654321:
            break
        elif isPandigital(s):
            print(s)
            exit()
        k += 1
    i -= 1