Strange numbers: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Cowgol) |
Not a robot (talk | contribs) (Add CLU) |
||
Line 616: | Line 616: | ||
130 131 135 136 138 141 142 146 147 149 |
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</pre> |
|||
=={{header|CLU}}== |
|||
<lang clu>digits = iter (n: int) yields (int) |
|||
while n>0 do |
|||
yield(n // 10) |
|||
n := n / 10 |
|||
end |
|||
end digits |
|||
strange = proc (n: int) returns (bool) |
|||
last: int := -1 |
|||
for d: int in digits(n) do |
|||
if last ~= -1 then |
|||
diff: int := int$abs(last-d) |
|||
if diff~=2 cand diff~=3 cand diff~=5 cand diff~=7 then |
|||
return(false) |
|||
end |
|||
end |
|||
last := d |
|||
end |
|||
return(true) |
|||
end strange |
|||
start_up = proc () |
|||
po: stream := stream$primary_output() |
|||
col: int := 0 |
|||
for n: int in int$from_to(100, 500) do |
|||
if ~strange(n) then continue end |
|||
stream$putright(po, int$unparse(n), 3) |
|||
col := col + 1 |
|||
if col = 10 then |
|||
stream$putc(po, '\n') |
|||
col := 0 |
|||
else |
|||
stream$putc(po, ' ') |
|||
end |
|||
end |
|||
end start_up</lang> |
|||
{{out}} |
|||
<pre>130 131 135 136 138 141 142 146 147 149 |
|||
161 163 164 168 169 181 183 185 186 202 |
161 163 164 168 169 181 183 185 186 202 |
||
203 205 207 241 242 246 247 249 250 252 |
203 205 207 241 242 246 247 249 250 252 |