public void unrank(final long rank, final int[] T) {
		if (T.length != k) {
			throw new IllegalArgumentException(
				"Invalid array size: %d != %d.".formatted(T.length, k)
			);
		}

		long r = rank;
		int x = 0;

		try {
			for (int i = 0; i < k; ++i) {
				long bc;
				while ((bc = BinomialCoefficient.apply(n - x - 1, k - i - 1)) <= r) {
					r -= bc;
					++x;
				}

				T[i] = x;
				++x;
			}
		} catch (IllegalArgumentException e) {
			throw new IllegalArgumentException("Invalid rank: " + rank, e);
		}
	}
Calculates the k-subset from the given {@code rank}.

@param rank the k-subset rank
@param T the array where the k-subset is written to
@throws IllegalArgumentException if {@code T.length != k} or when the
        given {@code rank} is invalid for {@code this} k-subset
@throws NullPointerException if {@code T} is {@code null}
jenetics.incubator/src/main/java/io/jenetics/incubator/combinatorial/KSubset.java