Task

Create and display the sequence of binary digits for a given   non-negative integer.

   The decimal value      5   should produce an output of               101
   The decimal value     50   should produce an output of            110010
   The decimal value   9000   should produce an output of    10001100101000

The results can be achieved using built-in radix functions within the language   (if these are available),   or alternatively a user defined function can be used.

The output produced should consist just of the binary digits of each number followed by a   newline.

There should be no other whitespace, radix or sign markers in the produced output, and leading zeros should not appear in the results.




       IDENTIFICATION DIVISION.
       PROGRAM-ID. SAMPLE.
 
       DATA DIVISION.
       WORKING-STORAGE SECTION.
 
         01 binary_number   pic X(21).
         01 str             pic X(21).
         01 binary_digit    pic X.
         01 digit           pic 9.
         01 n               pic 9(7).
         01 nstr            pic X(7).
 
       PROCEDURE DIVISION.
         accept nstr
         move nstr to n
         perform until n equal 0
           divide n by 2 giving n remainder digit
           move digit to binary_digit
           string binary_digit  DELIMITED BY SIZE
                  binary_number DELIMITED BY SPACE
                  into str
           move str to binary_number
         end-perform.
         display binary_number
         stop run.
 