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
def is_squarefree(n): if n == 1: return True quotient = n count = 1 while count == 1: prime, _ = first_prime_divisor(quotient) quotient, count = robust_divide(quotient, prime, include_count=True) if quotient == 1: return (count == 1) return False
def last5(n): if n < 8: # The remaining part is always divisible by # 2**5 for n > 7, these are special cases solutions = {0: 1, 1: 1, 2: 2, 3: 6, 4: 24, 5: 12, 6: 72, 7: 504} return solutions[n] if n <= 5 ** 5: residues = {} for i in range(1, n + 1): to_add = robust_divide(i, 5) # if to_add is not in residues, sets to 1 # (default 0 returned by get) residues[to_add] = residues.get(to_add, 0) + 1 else: residues = {} for residue in range(1, 5 ** 5): if residue % 5 != 0: residues[residue] = (n - residue) / (5 ** 5) + 1 max_power = int(floor(log(n) / log(5))) for power in range(1, max_power + 1): biggest_quotient = n / (5 ** power) for residue in range(1, 5 ** 5): if residue % 5 != 0: residues[residue] += ((biggest_quotient - residue) / (5 ** 5) + 1) product = 1 for residue, power in residues.items(): power_apply = power % (4 * (5 ** 4)) # PHI(5**5) product = (product * (residue ** power_apply)) % (5 ** 5) fives = num_factors_fact(n, 5) % (4 * (5 ** 4)) # PHI(5**5) inverse = inverse_mod_n(2, 5 ** 5) product = (product * (inverse ** fives)) % (5 ** 5) return (product * unit_a_zero_b(5 ** 5, 2 ** 5)) % 10 ** 5
def k_reduced(N): k_st = k_star(N) k_induced = robust_divide(robust_divide(k_st, 5), 2) shared_factors = gcd(k_induced, N) return k_induced / shared_factors