Anonymous user
Binary digits: Difference between revisions
→{{header|Ada}}
Line 246:
=={{header|Ada}}==
<lang Ada>with ada.text_io;use ada.text_io;
(if n=0 then "0" elsif n=1 then "1" else bin_image (n/2) & bin_image (n mod 2));
test_values : array (1..3) of Natural := (5,50,9000);
▲procedure Binary_Digits is
▲ function To_Binary(N: Natural) return String is
begin
for test of test_values loop put_line ("Output for" & test'img &" is " & bin_image (test)); end loop;
{{out}}
▲end Binary_Digits;</lang>
<pre>
Output for 5 is 101
Output for 50 is 110010
Output for 9000 is 10001100101000
</pre>
=={{header|Aime}}==
|