Strange plus numbers: Difference between revisions
Content added Content deleted
(Added solution for Action!) |
|||
Line 39: | Line 39: | ||
389 411 412 414 416 430 432 434 438 470 |
389 411 412 414 416 430 432 434 438 470 |
||
474 476 492 494 498 |
474 476 492 494 498 |
||
</pre> |
|||
=={{header|Action!}}== |
|||
<lang Action!>BYTE Func IsStrangePlusNumber(INT i) |
|||
BYTE ARRAY primes=[0 0 1 1 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0] |
|||
BYTE d,prev,first,sum |
|||
prev=255 |
|||
first=1 |
|||
WHILE i#0 |
|||
DO |
|||
d=i MOD 10 |
|||
IF prev#255 THEN |
|||
sum=d+prev |
|||
IF first=1 AND primes(sum)=0 THEN |
|||
RETURN (0) |
|||
FI |
|||
first=0 |
|||
FI |
|||
prev=d |
|||
i==/10 |
|||
OD |
|||
IF primes(sum)=0 THEN |
|||
RETURN (0) |
|||
FI |
|||
RETURN (1) |
|||
PROC Main() |
|||
INT i,count=[0] |
|||
FOR i=101 TO 499 |
|||
DO |
|||
IF IsStrangePlusNumber(i) THEN |
|||
PrintI(i) Put(32) |
|||
count==+1 |
|||
FI |
|||
OD |
|||
PrintF("%E%EThere are %I strange plus numbers",count) |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Strange_plus_numbers.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
111 112 114 116 120 121 123 125 129 141 143 147 149 161 165 167 202 203 205 207 211 212 |
|||
214 216 230 232 234 238 250 252 256 258 292 294 298 302 303 305 307 320 321 323 325 329 |
|||
341 343 347 349 383 385 389 411 412 414 416 430 432 434 438 470 474 476 492 494 498 |
|||
There are 65 strange plus numbers |
|||
</pre> |
</pre> |
||