Idoneal numbers: Difference between revisions
Content added Content deleted
(Added Swift solution) |
(J draft) |
||
Line 57: | Line 57: | ||
312 330 345 357 385 408 462 520 760 840 1320 1365 1848 |
312 330 345 357 385 408 462 520 760 840 1320 1365 1848 |
||
Calculations took 28.5862 ms</pre> |
Calculations took 28.5862 ms</pre> |
||
=={{header|J}}== |
|||
<syntaxhighlight lang=J style="width: max-content"> requre'stats' |
|||
_10]\(1+i.255)-.+/1*/\.|:1+3 comb 255 |
|||
1 2 3 4 5 6 7 8 9 10 |
|||
12 13 15 16 18 21 22 24 25 28 |
|||
30 33 37 40 42 45 48 57 58 60 |
|||
70 72 78 85 88 93 102 105 112 120 |
|||
130 133 165 168 177 190 210 232 240 253 |
|||
</syntaxhighlight> |
|||
Here, <code>comb</code> gives us all combinations of 3 numbers in ascending order in the given range (originally in the range 0..254 here, adding 1 shifts them to 1..255). Then we multiply all pairs from these combinations, sum the resulting products and remove those products from a sequence 1..255. (And we form the result into rows of 10 numbers each, to avoid an excessively long row of numbers.) |
|||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
Line 68: | Line 79: | ||
120 130 133 165 168 177 190 210 232 240 253 273 280 |
120 130 133 165 168 177 190 210 232 240 253 273 280 |
||
312 330 345 357 385 408 462 520 760 840 1320 1365 1848</pre> |
312 330 345 357 385 408 462 520 760 840 1320 1365 1848</pre> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
==={{header|Free Pascal}}=== |
==={{header|Free Pascal}}=== |