Charles Greathouse on Thu, 20 Sep 2012 15:21:34 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: forprime


> forfactored() is also interesting [ since one can quickly emulate
> forsquarefree(), fordisc(), etc. from this one ].
>
> Do you already have code for it ?

No, unfortunately.

I guess basic code wouldn't be too hard to write, and even though it
would be inefficient compared to optimized code it would be orders of
magnitude faster than running a for-loop with factor (to say nothing
of the case where you fail to write your own arithmetic functions and
end up factoring each number more than once, like sum(n=1,1e7,
sigma(n)+eulerphi(n)) ). Would you like me to take a whack at it?

It's a pity that many of the arithmetic functions use map_proto_G,
since that blocks the obvious path to "doing the right thing" with

f = factor(BIGNUMBER);
sigma(f)*eulerphi(f)

Charles Greathouse
Analyst/Programmer
Case Western Reserve University

On Thu, Sep 20, 2012 at 5:51 AM, Karim Belabas
<Karim.Belabas@math.u-bordeaux1.fr> wrote:
> * Charles Greathouse [2012-09-18 21:23]:
>> > As for me not looping over all composits, but looping over integers
>> > with a given number of divisors will be of great interest.
> [...]
>> But it's hard to think of examples off the top of my head. Very often
>> it just comes up in the middle of a problem where I find the need and
>> I just code something.
>
> To my surprise, I'm using it quite a lot today, when using GP as a
> simple calculator to quickly tune isprimepower(). It's actually
> quite convenient :-)
>
> forfactored() is also interesting [ since one can quickly emulate
> forsquarefree(), fordisc(), etc. from this one ].
>
> Do you already have code for it ?
>
> Thanks for suggesting this,
>
>     K.B.
> --
> Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
> Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
> 351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~belabas/
> F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
> `
>