Skip to main content
The National Cipher Challenge

Reply To: Programming

#98096
AspiringPenguin
Participant

Solution to Q2

def get_factors(number):
    factors = []
    for i in range(1, number+1):
        if number % i == 0:
            factors.append(i)
    return factors

primes = []
for i in range(2, 10000):
    if len(get_factors(i)) == 2:
        primes.append(i)

for i in range(1111, 9999):
    #Factors
    if len(get_factors(i)) != 60:
        continue
    #Primes
    for j in range(len(primes) - 42):
        if i == sum(primes[j:j+42]):
            print(i, primes[j:j+42])

Output: 5040 [23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229]

Report a problem