Spoj Question Why this Kolaveri Di? gives Nzec??
spoj.com/problems/WTK/
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(in.readLine());
while(t-->0){
int n=Integer.parseInt(in.readLine());
System.out.println(josephus(n,1));
}}
static int josephus(int n, int k){
if (n == 1)
return 1;
else
return (josephus(n-1,k+1)+k-1)%n+1;
}}