Count in octal: Difference between revisions

→‎[[Counting in octal#ALGOL 68]]: sample counts only to 17
(added Fortran)
(→‎[[Counting in octal#ALGOL 68]]: sample counts only to 17)
Line 28:
} while(i != 0);
}</lang>
=={{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].}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}}
<lang algol68>#!/usr/local/bin/a68g --script #
 
INT oct width = (bits width-1) OVER 3 + 1;
main:
(
FOR i TO 17 # max int # DO
printf(($"8r"8r n(oct width)dl$, BIN i))
OD
)</lang>
Output:
<pre>
8r00000000001
8r00000000002
8r00000000003
8r00000000004
8r00000000005
8r00000000006
8r00000000007
8r00000000010
8r00000000011
8r00000000012
8r00000000013
8r00000000014
8r00000000015
8r00000000016
8r00000000017
8r00000000020
8r00000000021
</pre>
 
=={{header|Fortran}}==