Strange numbers: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add BQN) |
(Added solution for Action!) |
||
Line 44: | Line 44: | ||
425 427 429 461 463 464 468 469 470 472 |
425 427 429 461 463 464 468 469 470 472 |
||
474 475 479 492 494 496 497 |
474 475 479 492 494 496 497 |
||
</pre> |
|||
=={{header|Action!}}== |
|||
<lang Action!>BYTE Func IsStrangeNumber(INT i) |
|||
BYTE ARRAY primes=[0 0 1 1 0 1 0 1 0 0] |
|||
BYTE d,diff,prev |
|||
prev=255 |
|||
WHILE i#0 |
|||
DO |
|||
d=i MOD 10 |
|||
IF prev#255 THEN |
|||
IF prev>d THEN |
|||
diff=prev-d |
|||
ELSE |
|||
diff=d-prev |
|||
FI |
|||
IF primes(diff)=0 |
|||
THEN RETURN (0) |
|||
FI |
|||
FI |
|||
prev=d |
|||
i==/10 |
|||
OD |
|||
RETURN (1) |
|||
PROC Main() |
|||
INT i,count=[0] |
|||
FOR i=101 TO 499 |
|||
DO |
|||
IF IsStrangeNumber(i) THEN |
|||
PrintI(i) Put(32) |
|||
count==+1 |
|||
FI |
|||
OD |
|||
PrintF("%E%EThere are %I strange numbers",count) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Strange_numbers.png Screenshot from Atari 8-bit computer] |
|||
<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 |
|||
There are 87 strange numbers |
|||
</pre> |
</pre> |
||