Perfect powers are m^k with k>:2 If one has to generate all m^k<:y than - you start with all m <:%:y - whereas I start with all k<:2^.y (since m>:2) and since there are (a lot) less k's than m's, pp2 is more efficient.
R.E. Boss > -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] [mailto:programming- > [EMAIL PROTECTED] Namens Arie Groeneveld > Verzonden: dinsdag 29 januari 2008 19:54 > Aan: Programming forum > Onderwerp: Re: [Jprogramming] Perfect powers > > Thank you for your reply. Impressive result! > > I can only come up with: > > pmt=:(1,[:/:[EMAIL PROTECTED]@;]<@([EMAIL PROTECTED])"0 0<:@<[EMAIL > PROTECTED])2+i.@<:@<[EMAIL PROTECTED]: > > pmx=: 3 : 0 > ri=.2+i.<:<.%:y > 1,/:~~.;ri<@([EMAIL PROTECTED])"0 0<:<.ri^.y > ) > > > =@@i > > > > R.E. Boss schreef: > > 10 ts'%. 200 200 [EMAIL PROTECTED] 1000' NB. benchmark > > 0.049750737 4330240 > > > > pp2=: 3 : '1,/:~~.;<@(^~ 2+i.@<:)/"1 (](],.<[EMAIL PROTECTED]:~) 2([EMAIL > > PROTECTED]@<:) 2<[EMAIL PROTECTED]) > y' > > NB. my solution > > > > 10 ts 'pp2 2000000' > > 0.00042491393 98048 > > > > ('3.0')(8!:2)%/ 10 ts &>'%. 200 200 [EMAIL PROTECTED] 1000';'pp2 2000000' > > 120 44 > > NB. 120 times faster and 44 times leaner than benchmark > > > > You had for pmx: > > > > ('3.0')(8!:2)%/ 0.0865417 3933888,:0.0036827 275712 > > 23 14 > > > > and for pmt: > > > > ('3.0')(8!:2)%/ 0.0865417 3933888,:0.006247 232448 > > 14 17 > > > > I checked 'pp 1765' with > http://www.research.att.com/~njas/sequences/A001597 > > and it matched. > > > > > > R.E. Boss > > > > > > > >> -----Oorspronkelijk bericht----- > >> Van: [EMAIL PROTECTED] [mailto:programming- > >> [EMAIL PROTECTED] Namens Arie Groeneveld > >> Verzonden: maandag 28 januari 2008 11:43 > >> Aan: Programming forum > >> Onderwerp: Re: [Jprogramming] Perfect powers > >> > >> Following a wise advise: here's is an indication of the speed of my pc: > >> > >> 10 ts'%. 200 200 [EMAIL PROTECTED] 1000' > >> 0.0865417 3933888 > >> > >> > >> @@i schreef: > >> > >>> JATK or let's say J4F. > >>> > >>> Generating a sequence of ordered perfect powers <= N > >>> ref. OLEIS A001597 > >>> > >>> I have a tacit (pmt) and a explicit (pmx) version both with the same > >>> algorithm > >>> > >>> *nb* Without ext. prec. > >>> > >>> pmt 200 > >>> 1 4 8 9 16 25 27 32 36 49 64 81 100 121 125 128 144 169 196 > >>> > >>> 10 ts 'pmt 2000000' > >>> 0.006247 232448 > >>> > >>> 10 ts 'pmx 2000000' > >>> 0.0036827 275712 > >>> > >>> > >>> x:{: pmx 2e6 > >>> 1999396 > >>> > >>> #pmt 1e6 NB. OLEIS A070428 > >>> 1111 > >>> > >>> > >>> Testing if a number > 1 is a perfect power: > >>> > >>> (1<[:+./[:{:__&q:) 220 > >>> 0 > >>> > >>> (1<[:+./[:{:__&q:) 32 > >>> 1 > >>> > >>> > >>> Just anxious to know (JATK) what's possible. :-) > >>> > >>> > >>> > >>> =@@i > >>> > >>> > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> > >>> > >>> > >>> > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > >> > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
