Conway's algorithm gives another hard way to generate primes:
https://www.jstor.org/stable/2690263 [only the first page of the article is
freely viewable, but that's all one needs].
NB. hacky J implementation
Num=: 17 78 19 23 29 77 95 77 1 11 13 15 15 55
Rat=: Num % x: 91 85 51 38 33 29 23 19 17 13 11 14 2 1
Input=: 2x
step=: ((= <.) {.@:# ])@:*&Rat
next=: 3 : 0
notdone=. 1
while. notdone do.
k=. 0 [ new=. Input=: step Input
while. 1<new do. k=. k+1 [ new=. new%2 end.
notdone=. new ~: 1
end.
k
)
next''
2
next''
3
next''
5
next''
7
next''
11
next''
13
next''
17
NB. ... etc.
--
Ewart Shaw [J.E.H.Shaw] http://www.ewartshaw.com [Work in Progress]
[email protected] http://www.facebook.com/ewart.shaw
3 ((4&({*.(=+/))++/=3:)@([:,/0&,^:(i.3)@|:"2^:2))&.>@]^:(i.@[) <#:3 6 2
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm