Bill Allombert on Fri, 21 Jun 2002 13:30:52 +0200

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

Re: rad function

On Mon, May 20, 2002 at 06:35:36PM +0200, Karim BELABAS wrote:
> On Mon, 20 May 2002, Jon Perry wrote:
> > Is there a rad function in Pari/GP?
> >
> > rad(n) is the square-free component of n, e.g. rad(12)=rad(2.2.3)=6
> No. You can use
> rad(n) =
> { local(p,i);
>   p = factor(n)[,1];
>   prod(i=1, length(p), p[i])
> }

Please do not put 'i' in local.  This declares a function-local variable with
the same name as the 'prod loop'-local variable i. This do no good and may be
extremly confusing, since the value of i is inchanged outside of 'prod()'.

??"User defined functions"@2
for more detail.

With gp2c-run , gcc will emit a warning about unused variable. warning: unused variable `i'



PS: with gp 2.2.1, you can just do