summaryrefslogtreecommitdiff
path: root/other/josephusK.cpp
blob: 522b584c6b653b772cd59aeb4decbf68767d118e (plain)
1
2
3
4
int josephus(int n, int k) { // Der letzte Überlebende, 0-basiert.
	if (n == 1) return 0;
	return (josephus(n - 1, k) + k) % n;
}