From 0ee667ca20e03c389a9e64b7c4eba5920f7ba0a9 Mon Sep 17 00:00:00 2001 From: Satyam Goel <64177535+hunt-s7@users.noreply.github.com> Date: Tue, 5 Oct 2021 19:15:46 +0530 Subject: [PATCH] Added Josephus Problem Solution --- DSA/Cpp/josephus.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 DSA/Cpp/josephus.cpp diff --git a/DSA/Cpp/josephus.cpp b/DSA/Cpp/josephus.cpp new file mode 100644 index 0000000..095a7b5 --- /dev/null +++ b/DSA/Cpp/josephus.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +int jos(int n,int k) +{ + if(n==1) + return 0; + + return (jos(n-1,k)+k)%n; + +} + + + +int main() +{ + int n,k; + cin>>n>>k; + + //circle starting from 0 + cout<