summaryrefslogtreecommitdiff
path: root/other/josephusK.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/josephusK.cpp')
-rw-r--r--other/josephusK.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/other/josephusK.cpp b/other/josephusK.cpp
new file mode 100644
index 0000000..8758fee
--- /dev/null
+++ b/other/josephusK.cpp
@@ -0,0 +1,4 @@
+int josephus(int n, int k) { // Gibt Index des letzten Überlebenden zurück, 0-basiert.
+ if (n == 1) return 0;
+ return (josephus(n - 1, k) + k) % n;
+} \ No newline at end of file