Skip to content

Instantly share code, notes, and snippets.

@azeemmohd
Created February 15, 2015 14:00
Show Gist options
  • Save azeemmohd/72435943f826b398d51a to your computer and use it in GitHub Desktop.
Save azeemmohd/72435943f826b398d51a to your computer and use it in GitHub Desktop.
public static String doStuff(int n, int j, int k) {
String s = formN(n);
return s.substring(j, k+1);
}
private static String formN(int n) {
StringBuilder sb = new StringBuilder("");
for(int i = 0; i<=n; i++){
sb.append(Integer.toBinaryString(i));
}
return sb.toString();
}
public static void main(String [] args) {
System.out.println(doStuff(5, 3, 6));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment