|
|
|
|
|
by underdeserver
609 days ago
|
|
I'm just here to point out that since Python 3.10, you don't need to import anything from typing anymore, you could use the built-in types for annotation: from math import prod
from itertools import combinations
def find_products(k=3, N=108) -> set[tuple[int, ...]]:
"""A list of all ways in which `k` distinct positive integers have a product of `N`."""
factors = {i for i in range(1, N + 1) if N % i == 0}
return {ints for ints in combinations(factors, k) if prod(ints) == N}
find_products()
|
|
Edit: I see that he imported the typing Set, which is deprecated, instead of collections.abc.Set, which is still useful, so your comment is correct.