Skip to content

Instantly share code, notes, and snippets.

@ZacBlanco
Created September 28, 2017 06:44
Show Gist options
  • Save ZacBlanco/aefea2808b11c345d40e6a55683577d2 to your computer and use it in GitHub Desktop.
Save ZacBlanco/aefea2808b11c345d40e6a55683577d2 to your computer and use it in GitHub Desktop.
import java.util.*;
public class myclass {
static boolean recursion_proper = false;
static int original_input = 123123123;
static int recursion_count = 0;
public static void main(String[] args) {
System.out.println("Hello, World!");
DecToBin(Integer.parseInt(args[0]));
System.out.println("Recursion called properly: " + recursion_proper);
System.out.println("DecToBin called " + recursion_count + " times");
}
public static String DecToBin(int x){
if (x > 0 && (original_input / x) % 2 == 0)
recursion_proper = true;
recursion_count++;
return StudentImplDecToBin(x);
}
public static String StudentImplDecToBin(int x){
if (x > 0){
String s = DecToBin(x/2);
return s + (x % 2);
}
return "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment