Eisenstein primes: Difference between revisions

Content added Content deleted
m (The norm should be the square of the modulus.)
m (→‎{{header|J}}: cleaner code)
Line 29: Line 29:
Implementation:
Implementation:
<syntaxhighlight lang=J>eisensteinprimes=: {{
<syntaxhighlight lang=J>eisensteinprimes=: {{
rY=: >.1.5%:y
rY=. >.1.5%:y
unit=: w^i.3
p1=. ,(w^i.3)*/(#~ 2= 3|]) p:i.rY
p1=: ,unit*/(#~ 2= 3|]) p:i.rY
'a b'=. |:(2#rY)#:I.,1 p: {{(x*x)+(y*y)-x*y}}"0/~i.rY
y{.(/: *:@|)p1,(,-)(a+b*w),a+b*-w
'a b'=: |:(2#rY)#:I.,1 p: {{(x*x)+(y*y)-x*y}}"0/~i.rY
y{.(/: |)p1,(,-)(a+b*w),a+b*-w
}}</syntaxhighlight>
}}</syntaxhighlight>