Count in octal: Difference between revisions

→‎{{header|REXX}}: added the REXX language. -- ~~~~
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
Line 849:
<lang Retro>octal
17777777777 [ putn cr ] iter</lang>
 
=={{header|REXX}}==
<lang rexx>
/*a clumsily way to count in octal.*/ numeric digits 100
 
/*┌────────────────────────────────────────────────────────────────────┐
│ Count all the protons (and electrons!) in the universe. │
│ │
│ According to Sir Author Eddington in 1938 at his Tamer Lecture at │
│ Trinity Collecge (Cambridge), he postulated that there are exactly │
│ │
│ 136 ∙ 2^245 │
│ │
│ protons in the universe and the same number of electrons, which is │
│ equal to around 1.57477e+79. │
│ │
│ Although, a modern extimate is around 10^80. │
└────────────────────────────────────────────────────────────────────┘*/
 
 
do j=0 to 136*(2**256) /*Sir Eddington, here we come ! */
!=x2b(d2x(j))
_=right(!,3*(length(_)%3+1),0)
o=
do k=1 to length(_) by 3
o=o'0'substr(_,k,3)
end
 
say 'base ten='j " octal="b2x(o)+0
if j>sourceline() then exit /*stop if #protons > program statements.*/
end
</lang>
Output:
<pre style="height:30ex;overflow:scroll">
base ten=0 octal=0
base ten=1 octal=1
base ten=2 octal=2
base ten=3 octal=3
base ten=4 octal=4
base ten=5 octal=5
base ten=6 octal=6
base ten=7 octal=7
base ten=8 octal=10
base ten=9 octal=11
base ten=10 octal=12
base ten=11 octal=13
base ten=12 octal=14
base ten=13 octal=15
base ten=14 octal=16
base ten=15 octal=17
base ten=16 octal=20
base ten=17 octal=21
base ten=18 octal=22
base ten=19 octal=23
base ten=20 octal=24
base ten=21 octal=25
base ten=22 octal=26
base ten=23 octal=27
base ten=24 octal=30
base ten=25 octal=31
base ten=26 octal=32
base ten=27 octal=33
base ten=28 octal=34
base ten=29 octal=35
</pre>
 
=={{header|Ruby}}==