Jean Claude Coez wrote:
> Choose an integer U0 such that (0 < U0 <= 64006 ) then define 
> a pseudo-random sequence as:
> Un+1 = ( 15091 * Un ) mod 64007
> while n < 40000 for instance.

Noting relationship between  U<=64006  and  mod 64007  , I might abstract out 
that constant, and write this as:

           f  =:  (| 15901&*)^:((1+[)`(<@:])`(1+?@:[))

For example:

           64006 f 40000
        39661 52597 29435 26751 41136 16003 35878 1687 ...

Then again, the constant  15901  also looks pretty arbitrary, so I might 
rewrite my solution as an adverb:
        
           F  =:  (&*) (|`) (`:6) (^:((1+[)`(<@:])`(1+?@:[)))

Then I would give  15901  as the adverb's argument, deriving a verb identical 
to the original f  :
   
           15901 F
        (| 15901&*)^:((1 + [)`(<@:])`(1 + ?@:[))

For example:
        
           64006 (15901 F) 40000
        61764 49963 6779 5091 47143 34866 39639 22810 ...

Hope this helps,

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to