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.




begin
    % prints an integer in binary - the number must be greater than zero     %
    procedure printBinaryDigits( integer value n ) ;
    begin
        if n not = 0 then begin
            printBinaryDigits( n div 2 );
            writeon( if n rem 2 = 1 then "1" else "0" )
        end
    end binaryDigits ;
 
    % prints an integer in binary - the number must not be negative          %
    procedure printBinary( integer value n ) ;
    begin
        if n = 0 then writeon( "0" )
                 else printBinaryDigits( n )
    end printBinary ;
 
    % test the printBinaryDigits procedure                                   %
    for i := 5, 50, 9000 do begin
        write();
        printBinary( i );
    end
 
end.