Sexy primes: Difference between revisions

Content added Content deleted
m (→‎{{header|J}}: spacing)
(→‎{{header|J}}: fix unsexy bug)
Line 966: Line 966:


sp =: dyad define
sp =: dyad define
's os' =. x NB. prime distance, group size
's os' =. x NB. prime distance, orgy size
p =. pngt y
p =. pngt y
o =. orgy p
o =. orgy p
Line 974: Line 974:
l =. (({.~ -) 5 <. #)&.> g NB. Last (max) 5 groups
l =. (({.~ -) 5 <. #)&.> g NB. Last (max) 5 groups


NB. I'm sure there's something clever with p-.s or similar,
( (#&.> g) ,. l ) ,~ (# ; _10&{.) }: p -. s NB. Unsexy numbers; }: is to exclude 1000033 per spec
NB. but (a) I don't want to think through it, and (b)
)</lang>
NB. it causes the kind of edge-case issues the spec warns
NB. about with 1000033
us =. _6 6 (] #~ [: +:/ 1 p: +/) p NB. Unsexy numbers
( (#&.> g) ,. l ) ,~ (# ; _10&{.) us
)

r =: 1000035 sp~ SEX,ORGY_SIZE
smoutput (;:'Group Count Examples') , (;:'Unsexy Pair Triplets Quadruplets Quintuplets') ,. r</lang>


{{out}}
{{out}}
Line 983: Line 991:
|Group |Count|Examples |
|Group |Count|Examples |
+-----------+-----+----------------------------------------------------------------------+
+-----------+-----+----------------------------------------------------------------------+
|Unsexy |78499|999883 999907 999917 999931 999953 999959 999961 999979 999983 1000003|
|Unsexy |48627|999853 999863 999883 999907 999917 999931 999961 999979 999983 1000003|
+-----------+-----+----------------------------------------------------------------------+
+-----------+-----+----------------------------------------------------------------------+
|Pair |16386|999371 999377 |
|Pair |16386|999371 999377 |