Anonymous user
Sexy primes: Difference between revisions
→{{header|J}}: max SEX and ORGY_SIZE free parameters rather than global constants (this was inconsistent before)
m (→{{header|J}}: capped fork -> Atop) |
(→{{header|J}}: max SEX and ORGY_SIZE free parameters rather than global constants (this was inconsistent before)) |
||
Line 951:
=={{header|J}}==
<lang j>
NB. The 1 _1 p: ... logic here allows the input value to
NB. be included in the list in the case it itself is prime
Line 960 ⟶ 957:
NB. Add 6 and see which sums appear in input list
sexy =: ] #~
NB. Iterate "sexy" logic up to orgy size
orgy =: sexy&.>^:(
sp =: dyad define
'pd os' =. x NB. x is prime distance (6), orgy size (5)
p =. pngt y
o =. x orgy p
g =. o +/&.> <\ +/\ _1 |.!.0 os # pd NB. Groups
Line 980 ⟶ 977:
us =. p (] #~ 1 +:/@:p: +/)~ (+,-) pd NB. Unsexy numbers
( (#&.> g) ,. l ) ,~ (# ; _10&{.) us
)</lang>
{{out}}
<lang j> r =:
smoutput (;:'Group Count Examples') , (;:'Unsexy Pair Triplets Quadruplets Quintuplets') ,. r
+-----------+-----+----------------------------------------------------------------------+
|Group |Count|Examples |
|