Strange numbers: Difference between revisions

Added XPL0 example.
(Add PL/M)
(Added XPL0 example.)
Line 2,369:
<pre>
Found 853423 10-digit strange numbers beginning with 1
</pre>
 
=={{header|XPL0}}==
Takes 49 seconds on Raspberry Pi 4.
<lang XPL0>func Strange(N);
int N, A, B, D;
[N:= N/10;
A:= rem(0);
loop [N:= N/10;
B:= rem(0);
D:= abs(A-B);
if D#2 & D#3 & D#5 & D#7 then return false;
if N = 0 then return true;
A:= B;
];
];
 
int Cnt, N;
[Cnt:= 0;
for N:= 100 to 500 do
if Strange(N) then
[Cnt:= Cnt+1;
IntOut(0, N);
if rem(Cnt/20) = 0 then CrLf(0) else ChOut(0, ^ );
];
CrLf(0);
Cnt:= 0;
for N:= 1_000_000_000 to 1_999_999_999 do
if Strange(N) then
Cnt:= Cnt+1;
IntOut(0, Cnt);
]</lang>
 
{{out}}
<pre>
130 131 135 136 138 141 142 146 147 149 161 163 164 168 169 181 183 185 186 202
203 205 207 241 242 246 247 249 250 252 253 257 258 270 272 274 275 279 292 294
296 297 302 303 305 307 313 314 316 318 350 352 353 357 358 361 363 364 368 369
381 383 385 386 413 414 416 418 420 424 425 427 429 461 463 464 468 469 470 472
474 475 479 492 494 496 497
853423
</pre>
772

edits