def main(verbose=False): prime_max = 10 ** 5 PRIMES = sieve(prime_max) found = [] n = 2 while len(found) < 25: n += 1 if n > prime_max: prime_max *= 10 PRIMES = sieve(prime_max) if n % 2 == 0 or n % 5 == 0 or n in PRIMES: continue basis = n if n % 3 == 0: basis = 9 * n if (n - 1) % order_mod_n(10, basis) == 0: found.append(n) if verbose: return ('%s.\nAs a check, the first five values are calculated to be ' '%s, as stated.' % (sum(found), ', '.join(str(num) for num in found[:5]))) else: return sum(found)
def hyper_exponentiate(a, b, modulus): if modulus == 1: return 1 elif modulus == 2: return a % 2 if b == 1: return a % modulus a_order = order_mod_n(a, modulus) return (a ** hyper_exponentiate(a, b - 1, a_order)) % modulus
def main(verbose=False): max_a = 0 n = 10 ** 6 while max_a <= 10 ** 6: n += 1 if gcd(10, n) == 1: basis = n if n % 3 == 0: basis = 9 * n curr_order = order_mod_n(10, basis) if curr_order > max_a: max_a = curr_order return n
def main(verbose=False): # We need to find the residue of P modulo 5**10 # since we already know the residue modulo 2**10 actual_exponent = 7830457 % order_mod_n(2, 5 ** 10) # want to find 2 raised to this exponent power_of_two = 1 for i in range(actual_exponent): power_of_two = (2 * power_of_two) % 5 ** 10 residue = (28433 * power_of_two + 1) % 5 ** 10 unit_two_null_five = unit_a_null_b(2 ** 10, 5 ** 10) unit_five_null_two = unit_a_null_b(5 ** 10, 2 ** 10) return (1 * unit_two_null_five + residue * unit_five_null_two) % 10 ** 10
def main(verbose=False): max_index = -1 max_block_size = -1 for i in range(1, 1000): stripped_val = robust_divide(robust_divide(i, 2), 5) if stripped_val == 1: block_size = 0 else: block_size = order_mod_n(10, stripped_val) if block_size > max_block_size: max_block_size = block_size max_index = i return max_index