Count in octal: Difference between revisions

Content added Content deleted
(GP)
(Added Ada code)
Line 2: Line 2:


The task is to produce a sequential count in octal, starting at zero, and using an increment of a one for each consecutive number. Each number should appear on a single line, and the program should count until terminated, or until the maximum value that can be held within the system registers is reached (for a 32 bit system using unsigned registers, this value is 37777777777 octal).
The task is to produce a sequential count in octal, starting at zero, and using an increment of a one for each consecutive number. Each number should appear on a single line, and the program should count until terminated, or until the maximum value that can be held within the system registers is reached (for a 32 bit system using unsigned registers, this value is 37777777777 octal).

=={{header|Ada}}==
<lang Ada>with Ada.Text_IO;

procedure Octal is
X: Integer;
package IIO is new Ada.Text_IO.Integer_IO(Integer);
begin
Ada.Text_IO.Put_Line("Enter X; I'll count from 0 to 2**X in octal");
IIO.Get(X);
for I in 0 .. 2**X -1 loop
IIO.Put(I, Base => 8, Width => ((X+14)/3));
end loop;
end Octal;</lang>
Output:
<pre>>./octal
Enter X; I'll count from 0 to 2**X in octal
5
8#0# 8#1# 8#2# 8#3# 8#4# 8#5# 8#6# 8#7# 8#10# 8#11# 8#12# 8#13# 8#14# 8#15# 8#16# 8#17# 8#20# 8#21# 8#22# 8#23# 8#24# 8#25# 8#26# 8#27# 8#30# 8#31# 8#32# 8#33# 8#34# 8#35# 8#36# 8#37#</pre>

=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny].}}
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny].}}