Given integers k and n, generate a sequence of n unique k-tuples of pairwise coprime integers. Every such tuple must occur once eventually, that is, for any existing k-tuple of pairwise coprime integers, some n will eventually generate it.
The output may be printed or evaluated in any list/tuple-like form.
Definitions
- Two numbers
aandbare coprime ifgcd(a, b) = 1, i.e. they share no common divisor other than 1. - A tuple of
knumbers(a1, a2, ..., ak)is pairwise coprime if every pair of numbers in the tuple is coprime.
Examples
k = 1, n = 5 -> [[1],[2],[3],[4],[5]] k = 2, n = 7 -> [[2,1],[3,1],[3,2],[4,1],[4,3],[5,1],[5,2]] k = 3, n = 10 -> [[3,2,1],[4,3,1],[5,2,1],[5,3,1],[5,3,2],[5,4,1],[5,4,3],[6,5,1],[7,2,1],[7,3,1]] k = 4, n = 2 -> [[5,3,2,1],[5,4,3,1]] k = 5, n = 0 -> [] Notes
- Standard code golf rules, shortest code wins.
kis assumed to be positive, andnnon-negative.- The numbers within each tuple must be positive, distinct, and may appear in any order.
- Uniqueness is up to ordering: e.g.
(1,2,3)is the same as(1,3,2). - Good luck and have fun!
k = 0should be excluded from the input range, as there is only one possible k-tuple[]. \$\endgroup\$