import java.util.Scanner;
import java.util.Arrays;

public class Main
{
                                      
    public static void main(String[] args) {
        
        int num;
        int num1;
        test t;
        
        //do {
        Scanner reader = new Scanner(System.in);  // Reading from System.in
        System.out.println("Enter a number no larger than 2,000,000,000: ");
        
        num = reader.nextInt(); // Scans the next token of the input as an int.
        
        System.out.println("Enter a larger number no larger than 2,000,000,000: ");
        
        num1 = reader.nextInt(); // Scans the next token of the input as an int.
        
        //once finished
        reader.close();
        
        int sizeArray = (num1-num)+1;   // this is to ensure the size of array to store decimals and binary conversions 
                                        //  is inclusive of the lower and upper limit
        
        int arrayBitwiseAnd = sizeArray * (sizeArray -1);  // this size ensures all combinations of BitWiseAnd can be stored
        
        System.out.println("array to be created of size: " + sizeArray + " to hold decimals");
        System.out.println("array to be created of size: " + sizeArray + " to hold decimals in binary form");
        System.out.println("array to be created of size: "  + arrayBitwiseAnd + " to store all possible bitwise AND");
        System.out.println("\n");
        
        
        //  THE FUNCTION HAS TO START here
        
       t= new test(num,num1,sizeArray, arrayBitwiseAnd);
     
      }   
  
}


class test
{
    int binary[] = new int[31];   //This is to define 31 bit array to hold binary value. Maximum value is over 2 billion.
                                      // This is Java's limitation.
        
        int j;  //counter
        
        int i;   //counter
        String conversion;   // this will be used to output binary conversion on screen without having to iterate through loop again
        int num;

       int sizeArray;
       int arrayBitwiseAnd;
       int bitwiseAnd[] = new int[arrayBitwiseAnd];
    
   public test(int num, int num1, int sizeArray, int arrayBitwiseAnd)
        {
            this.sizeArray=sizeArray;
            this.num=num;
            this.arrayBitwiseAnd=arrayBitwiseAnd;
            int rangeDecimal[] = new int[sizeArray];       // this will hold all the decimal values to be converted
            
            
            
            // This is a test to check that all decimal numbers have been inputted into array
            for (int i=0; i<sizeArray;i++)
            {
                rangeDecimal[i]=num+i;
                System.out.println("Decimal number in array is: " + rangeDecimal[i]);
            
            // This is tricky part... Unsure of how to store array of binary conversions.
            int rangeBinary[][] = new int[sizeArray][32];  //this will hold the 
            
            
        System.out.println("The decimal number is:  " + rangeDecimal[i]);
        
        int length = binary.length;
       
        System.out.println("/n");
        System.out.println("*** This program will convert decimal " + rangeDecimal[i]+ "  into binary");
        
        //Execute a for loop to check modulus (i.e no remainder)
        
        
        for (j=length-1; j>=0; j--)
        {
            
                int divisor = (int)(Math.pow(2,j));
                
                if (rangeDecimal[i] - divisor >=0)
        {  
           
            binary[(length-1)-j] = 1;
            rangeDecimal[i]=rangeDecimal[i]-divisor;
          
        }
                
            }
            
            conversion = Arrays.toString(binary);
            
         System.out.println("The binary version is:  " + conversion );
            
            
            
        }
        }
}