Jump to content

Ludic numbers: Difference between revisions

Added Arturo implementation
m (→‎{{header|Phix}}: added syntax colouring the hard way)
(Added Arturo implementation)
Line 637:
Triplets < 250:
{1, 3, 7}, {5, 7, 11}, {11, 13, 17}, {23, 25, 29}, {41, 43, 47}, {173, 175, 179}, {221, 223, 227}, {233, 235, 239}"</lang>
 
=={{header|Arturo}}==
 
<lang rebol>
ludicGen: function [nmax][
result: [1]
lst: new 2..nmax+1
i: 0
worked: false
while [and? [not? empty? lst] [i < size lst]][
item: lst\[i]
result: result ++ item
del: 0
worked: false
while [del < size lst][
worked: true
remove 'lst .index del
del: dec del + item
]
if not? worked -> i: i + 1
]
return result
]
 
ludics: ludicGen 25000
 
print "The first 25 ludic numbers:"
print first.n: 25 ludics
 
leThan1000: select ludics => [& =< 1000]
print ["\nThere are" size leThan1000 "ludic numbers less than/or equal to 1000\n"]
 
print ["The ludic numbers from 2000th to 2005th are:" slice ludics 1999 2004 "\n"]
 
print "The triplets of ludic numbers less than 250 are:"
print map select ludics 'x [
all? @[ x < 250
contains? ludics x+2
contains? ludics x+6
]
] 't -> @[t, t+2, t+6]</lang>
 
{{out}}
 
<pre>The first 25 ludic numbers:
1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107
 
There are 142 ludic numbers less than/or equal to 1000
The ludic numbers from 2000th to 2005th are: [21475 21481 21487 21493 21503 21511]
The triplets of ludic numbers less than 250 are:
[1 3 7] [5 7 11] [11 13 17] [23 25 29] [41 43 47] [173 175 179] [221 223 227] [233 235 239]</pre>
 
=={{header|AutoHotkey}}==
1,532

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.