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