Codechef -- King of the Ring

Problem Link 

Solution : 

/// Author : Shohan
/// Problem Type : Josephus Problem
#include<stdio.h>
int josephus(int a,int b);
int main()
{
int n,m,p;
while(scanf("%d %d",&m,&n)==2){
p=josephus(m,n);
printf("%d\n",p);
}
return 0;
}
int josephus(int n,int k)
{
if(n==1)
return 1;
else
return (josephus(n-1,k)+k-1)%n+1;
}
view raw gistfile1.cpp hosted with ❤ by GitHub