summaryrefslogtreecommitdiff
path: root/sonstiges/josephusK.cpp
blob: e3fcac233af16ab049ede1a6d62983dbb067245f (plain)
1
2
3
4
int josephus(int n, int k) { //returns the number of the last survivor (0 based)
	if (n == 1) return 0;
	return (josephus(n - 1, k) + k) % n;
}