For this Question: Given a number N. The task is to generate and print all binary numbers with decimal values from 1 to N.

Try solving this using a queue.The only line of input contains a single integer N.

1 <= N <= 50000Print all binary numbers with decimal values from 1 to N in a single line.Sample Input:
5

Sample Output:
1 10 11 100 101, I have written this Solution Code: import java.util.*;
import java.math.*;
import java.io.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        StringBuilder s=new StringBuilder("");
        for(int i=1;i<=n;i++){
            s.append(Integer.toBinaryString(i)+" ");
        }
        System.out.print(s);
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?