By the way, using Andrew Nikitin's idea, together with removing
an unnecessary use of rank in the implementation,

   timer=: 6!:2
   y=: 2x+i.1e5

   timer '5 p: y'  NB. J7.01
0.796005

   timer '5 p: y'  NB. J6.02
2.7178



----- Original Message -----
From: Roger Hui <[email protected]>
Date: Wednesday, November 4, 2009 2:02
Subject: Re: [Jprogramming] totient
To: Programming forum <[email protected]>

> Neat.  Thanks for the note.
> 
> 
> 
> ----- Original Message -----
> From: Andrew Nikitin <[email protected]>
> Date: Tuesday, November 3, 2009 13:02
> Subject: [Jprogramming] totient
> To: J programming <[email protected]>
> 
> > 
> > I came up with cute expression for totient, which in addition 
> to 
> > being cute, also seems faster than 5&p. (in j601)
> > 
> > Here it is:
> > 
> >    tot=:(- ~:)&.q:
> > 
> >    (5&p: -: tot) 2+i.100000x
> > 1
> > 
> > 
> >    6!:2 '5 p: 2+i.100000x'
> > 2.51881
> >    6!:2 '(- ~:)&.q: 2+i.100000x'
> > 0.676987
> >    6!:2 '5 p: 2+i.100000'
> > 0.409061
> >    6!:2 '(- ~:)&.q: 2+i.100000'
> > 0.195733
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to