Indeed.  From,

FRACTRAN - Wikipedia
https://en.wikipedia.org/wiki/FRACTRAN

and

RosettaCode Fractran
http://www.rosettacode.org/wiki/Fractran#Tacit_version

one can get (beware of line wrapping!),

   FRACTRAN=. (((({~ (1 i.~ (= <.)))@:* ::]^:)(`]))([`))(`:6)


   ( primes=. ('FRACTRAN'f.) ((1 }. 2 ^. (#~ *./@:e.&2 0"1@:q:))@:) )
((((({ ~ (1 i.~ (= <.)))@:* ::]^:)(`]))([`))(`:6))((1 (}.) 2 ^. (#~
*./@:e.&2 0"1@:q:))@:)



   (17r91 78r85 19r51 23r38 29r33 77r29 95r23 77r19 1r17 11r13 13r11 15r14
15r2 55r1) (<55555) primes 2

2 3 5 7 11 13 17 19 23 29 31

Cheers!





On Sun, Jul 17, 2022 at 7:05 AM Ewart Shaw <[email protected]> wrote:
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to