Duffinian numbers: Difference between revisions
Content added Content deleted
(Added C++ solution) |
(Added Sidef) |
||
Line 587: | Line 587: | ||
(72961, 72962, 72963) (76175, 76176, 76177) (79523, 79524, 79525) (84099, 84100, 84101) |
(72961, 72962, 72963) (76175, 76176, 76177) (79523, 79524, 79525) (84099, 84100, 84101) |
||
(86527, 86528, 86529) (94177, 94178, 94179) (108899, 108900, 108901) (121103, 121104, 121105)</pre> |
(86527, 86528, 86529) (94177, 94178, 94179) (108899, 108900, 108901) (121103, 121104, 121105)</pre> |
||
=={{header|Sidef}}== |
|||
<lang ruby>func is_duffinian(n) { |
|||
n.is_composite && n.is_coprime(n.sigma) |
|||
} |
|||
say "First 50 Duffinian numbers:" |
|||
say 50.by(is_duffinian) |
|||
say "\nFirst 15 Duffinian triplets:" |
|||
15.by{|n| ^3 -> all {|k| is_duffinian(n+k) } }.each {|n| |
|||
printf("(%s, %s, %s)\n", n, n+1, n+2) |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
First 50 Duffinian numbers: |
|||
[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, 217] |
|||
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|Wren}}== |
=={{header|Wren}}== |