Strange unique prime triplets: Difference between revisions

Content added Content deleted
(→‎J: fully tacit)
(→‎J: pick combinations directly)
Line 339: Line 339:


=={{header|Arturo}}==
=={{header|Arturo}}==

<syntaxhighlight lang="arturo">findTriplets: function [upTo][
<syntaxhighlight lang="arturo">findTriplets: function [upTo][
results: []
results: []
Line 936: Line 935:
74588542
74588542
</pre>
</pre>

=={{header|Factor}}==
=={{header|Factor}}==
<syntaxhighlight lang="factor">USING: formatting io kernel math math.combinatorics math.primes
<syntaxhighlight lang="factor">USING: formatting io kernel math math.combinatorics math.primes
Line 1,202: Line 1,202:


=={{header|Fōrmulæ}}==
=={{header|Fōrmulæ}}==

{{FormulaeEntry|page=https://formulae.org/?script=examples/Strange_unique_prime_triplets}}
{{FormulaeEntry|page=https://formulae.org/?script=examples/Strange_unique_prime_triplets}}


Line 1,448: Line 1,447:


=={{header|J}}==
=={{header|J}}==
<syntaxhighlight lang="j"> cb=. ;@:({. <@,. @\.)}.
<syntaxhighlight lang="j">cb=. ;@:({. <@,. @\.)}.
comb3=. ]cb cb@i.
comb3=. ]cb cb
triplets=. (#~ 1 p: +/"1)@({~ comb3@#)@(i.&.(p:inv))
triplets=. (#~ 1 p: +/"1)@comb3@(i.&.(p:inv)"0)</syntaxhighlight>
{{out}}

triplets 30
<pre> triplets 30
3 5 11
3 5 11
3 5 23
3 5 23
Line 1,496: Line 1,495:
19 23 29
19 23 29


#@triplets 1000
#@triplets 30 1000
241580</syntaxhighlight>
42 241580</pre>


=={{header|Java}}==
=={{header|Java}}==
Line 1,678: Line 1,677:
Stretch goal: 241580
Stretch goal: 241580
</pre>
</pre>

=={{header|Julia}}==
=={{header|Julia}}==
<syntaxhighlight lang="julia">using Primes
<syntaxhighlight lang="julia">using Primes
Line 2,298: Line 2,298:


=={{header|Quackery}}==
=={{header|Quackery}}==

<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].