def problem_43(): def condition(num): snum = str(num) return (int(snum[1:4]) % 2 == 0 and \ int(snum[2:5]) % 3 == 0 and \ int(snum[3:6]) % 5 == 0 and \ int(snum[4:7]) % 7 == 0 and \ int(snum[5:8]) % 11 == 0 and \ int(snum[6:9]) % 13 == 0 and \ int(snum[7:10]) % 17 == 0) num_sum = 0 for pandigital in utils.pandigitals(length = 9, include_0 = True): if condition(pandigital): num_sum += pandigital return num_sum
def problem_43(): def condition(num): snum = str(num) return (int(snum[1:4]) % 2 == 0 and \ int(snum[2:5]) % 3 == 0 and \ int(snum[3:6]) % 5 == 0 and \ int(snum[4:7]) % 7 == 0 and \ int(snum[5:8]) % 11 == 0 and \ int(snum[6:9]) % 13 == 0 and \ int(snum[7:10]) % 17 == 0) num_sum = 0 for pandigital in utils.pandigitals(length=9, include_0=True): if condition(pandigital): num_sum += pandigital return num_sum
def problem_41(): for length in xrange(9, 1, -1): options = utils.pandigitals(length) for num in options: if utils.is_prime(num): return num