Last active
July 5, 2018 12:38
-
-
Save sjdhanasekaran/13aa521bf06c1f93d2af9e63d907709e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class JosephusProblem { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Enter the number of Persons : "); | |
int i=sc.nextInt(); | |
String s = Integer.toBinaryString(i); | |
String s1 = s.substring(1) +s.charAt(0); | |
int output = Integer.parseInt(s1, 2); | |
System.out.println(output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment