Karim Belabas on Sun, 27 Nov 2022 15:11:33 +0100


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

Re: A071521(n)


* Bill Allombert [2022-11-27 12:57]:
> On Sun, Nov 27, 2022 at 11:21:14AM +0100, Karim Belabas wrote:
> > Hi,
> > 
> >   I didn't check the definition of A071521 in OEIS but I guess the
> > problem is the unexpected (if one is used to C) semantic of the 'a op= b'
> > operator in PARI/GP, whose value is A = a op b (and not 'a' !). 
> 
> The following C program print 5 , not 1:
> 
> #include <stdio.h>
> int main(void)
> {
>   long a = 1, b;
>   b = a*=5;
>   printf("%ld\n",b);
>   return 0;
> }
> 
> (all PARI/GP versions also return 5).

Yes, sorry. You're right about C of course, but I'm sure there must be
languages out there where my above parenthetical comment applies :-)

When thinking about what could have caused the original coding mistake,
the semantics of PARI's a++ sprang to mind (which corresponds to prefix
++a in C; there's no unary PARI operator corresponding to C's a++), then
I wrote this confusing bit. Thanks for the correction !

Cheers,

    K.B.
--
Karim Belabas  /  U. Bordeaux,  vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
`