Duffinian numbers: Difference between revisions

Added Arturo implementation
m (Promote. multiple implementations, no questions)
(Added Arturo implementation)
Line 250:
12481 12482 12483
13447 13448 13449"</lang>
 
=={{header|Arturo}}==
 
<lang rebol>duffinian?: function [n]->
and? [not? prime? n]
[
fn: factors n
[1] = intersection factors sum fn fn
]
 
first50: new []
i: 0
while [50 > size first50][
if duffinian? i -> 'first50 ++ i
i: i + 1
]
 
print "The first 50 Duffinian numbers:"
loop split.every: 10 first50 'row [
print map to [:string] row 'item -> pad item 3
]
 
first15: new []
i: 0
while [15 > size first15][
if every? i..i+2 => duffinian? [
'first15 ++ @[@[i, i+1, i+2]]
i: i+2
]
i: i + 1
]
 
print ""
print "The first 15 Duffinian triplets:"
loop split.every: 5 first15 'row [
print map row 'item -> pad.center as.code item 17
]</lang>
 
{{out}}
 
<pre>The first 50 Duffinian numbers:
1 4 8 9 16 21 25 27 32 35
36 39 49 50 55 57 63 64 65 75
77 81 85 93 98 100 111 115 119 121
125 128 129 133 143 144 155 161 169 171
175 183 185 187 189 201 203 205 209 215
 
The first 15 Duffinian triplets:
[63 64 65] [323 324 325] [511 512 513] [721 722 723] [899 900 901]
[1443 1444 1445] [2303 2304 2305] [2449 2450 2451] [3599 3600 3601] [3871 3872 3873]
[5183 5184 5185] [5617 5618 5619] [6049 6050 6051] [6399 6400 6401] [8449 8450 8451]</pre>
 
=={{header|C++}}==
1,532

edits