Prime triangle: Difference between revisions

Content added Content deleted
(J)
m (→‎{{header|J}}: more consistent use of spaces in syntactically significant locations)
Line 511: Line 511:
p=. is_prime L{~y+0 1
p=. is_prime L{~y+0 1
if. N=y do. p return.end.
if. N=y do. p return.end.
i=.Y=.y+1
i=. Y=. y+1
if. p do. if. is_prime_triangle Y do. 1 return.end.end.
if. p do. if. is_prime_triangle Y do. 1 return.end.end.
while. M>i=.i+2 do.
while. M>i=.i+2 do.
Line 526: Line 526:
NB. y is index into L and thus analogous to *a
NB. y is index into L and thus analogous to *a
p=. is_prime L{~y+0 1
p=. is_prime L{~y+0 1
if.N=y do.
if. N=y do.
count=: count+p return.
count=: count+p return.
end.
end.
i=.Y=.y+1
i=. Y=. y+1
if. p do. prime_triangle_counter Y end.
if. p do. prime_triangle_counter Y end.
while. M>i=.i+2 do.
while. M>i=. i+2 do.
if. is_prime L{~y,i do.
if. is_prime L{~y,i do.
L=: (L{~Y,i) (i,Y)} L
L=: (L{~Y,i) (i,Y)} L