Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Binary2{
- public static void main(String[] args) {
- int input;
- Scanner console = new Scanner(System.in);
- System.out.print("Enter number to convert to binary: ");
- input = console.nextInt();
- Binary(input);
- }
- public static void Binary(int num) {
- if (num>0) {
- Binary(num/2);
- System.out.print(num%2 + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement