Upside-down numbers: Difference between revisions

Content added Content deleted
(Added Go)
(Added XPL0 example.)
Line 437: Line 437:
500,000th : 729,664,644,183
500,000th : 729,664,644,183
5,000,000th : 82,485,246,852,682
5,000,000th : 82,485,246,852,682
</pre>

=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">func HasZero(N); \Return 'true' if N contains a zero digit
int N;
[repeat N:= N/10;
if rem(0) = 0 then return true;
until N = 0;
return false;
];

proc IntRevOut(N); \Show N upside down
int N;
[repeat N:= N/10;
IntOut(0, 10-rem(0));
until N = 0;
];

int Count, TenPower, Limit, Out5, LeftSide;
[Count:= 1; TenPower:= 1; Limit:= 500;
IntOut(0, 5); ChOut(0, 9\tab\);
loop [Out5:= false;
repeat LeftSide:= TenPower;
repeat if not HasZero(LeftSide) then
[Count:= Count+1;
if Count <= 50 then
[IntOut(0, LeftSide);
if Out5 then IntOut(0, 5);
IntRevOut(LeftSide);
ChOut(0, 9\tab\);
if rem(Count/10) = 0 then CrLf(0);
];
if Count = Limit then
[IntOut(0, Count); Text(0, "th: ");
IntOut(0, LeftSide);
if Out5 then IntOut(0, 5);
IntRevOut(LeftSide);
CrLf(0);
Limit:= Limit*10;
if Limit > 5_000_000 then quit;
];
];
LeftSide:= LeftSide+1;
until LeftSide = TenPower*10;
Out5:= not Out5;
until not Out5;
TenPower:= TenPower*10;
];
]</syntaxhighlight>
{{out}}
<pre>
5 19 28 37 46 55 64 73 82 91
159 258 357 456 555 654 753 852 951 1199
1289 1379 1469 1559 1649 1739 1829 1919 2198 2288
2378 2468 2558 2648 2738 2828 2918 3197 3287 3377
3467 3557 3647 3737 3827 3917 4196 4286 4376 4466
500th: 494616
5000th: 56546545
50000th: 6441469664
500000th: 729664644183
5000000th: 82485246852682
</pre>
</pre>