summaryrefslogtreecommitdiff
path: root/content/other/josephusK.cpp
blob: 5025f89165cc86aa18b3b1c4197fab469f922d7c (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;
}