R J Cano on Sun, 14 May 2017 15:06:55 +0200

• To: pari-users@pari.math.u-bordeaux.fr
• From: R J Cano <0xcc00ffffeeee@gmail.com>
• Date: Sun, 14 May 2017 08:06:46 -0500
• Delivery-date: Sun, 14 May 2017 15:06:55 +0200
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=YvMO01ThoC7BiQLs1eRPZAXxC76Me3n/SfflWHdLXt0=; b=mLkJNZTPu3UemoIf0phKQz1UMDZQ1A36E3UTRUn6RQcA9t/XjDDC96yERRbVMjhghZ Oz8J2JAxuQfWdLPaahQgrYGTlUeVDfPY2TBRZJ7GvQFj4FUtrchlsKemJvHrrL6H8tG9 0THgevyTS+vZIA3I5sCaRzmKXxr9r7ATAMJPMk9pulTon4Cy2eNTs++SLXc5vHVspVPw TN0mbczfPOAN030562LEH0K7wqQqMCprsHI8t5asf4yx3tLrTfvQOvisVXR6LxPGoBja OjHSvT/HWwTEkpeJi4Gtrx4lTaAb5jaDDWC5ALohWnCUI3R06C6eh+oHu7DtEyliq8w3 iNeg==

```Greetings!,

Dear Bill,

I found out this one, based only on Mersenne numbers: Those 2^x-1;

isperm(N)={
my(x, y, z, t, t0);
for(B=2, max(2, N-1),
y=digits(N, B);
x*=0;
for(i=1, #y,
t=1<<y[i];
if(bitand(x, t),
x*=0;
break,
x+=t)
);
if(x,
t0=!(x%2);
x++;
x+=t0);
t=ispower(x, , &z);
if(t&&z==2,
return(B)
)
);
return(0)
}

It replies the question: What is the least base in which N is
expressed as a permutation for the first non negative integers,
entering all of them. It does match excepting for 3 N in {0,3,4} with
the definition www.oeis.org/A211187;

Cheers,

Remy.

P.S.:  I took into account some subtle details, regarding C/C++
instructions optimization, in order to take them in advantage when
compiling code with GP2C; For example, at the second program t0 might
be omitted by using something like: x+=1+!(x%2); instead of the
separated sequence of operators. There is none effect at first glance,
but when using both versions for generating for example 10 thousand
terms... this one is faster. Indeed with the aid of GP2C and compared
against Mathematica code, the time is reduced to a half.
```
```isperm(N)={
my(x, y, z, t, t0);
for(B=2, max(2, N-1),
y=digits(N, B);
x*=0;
for(i=1, #y,
t=1<<y[i];
if(bitand(x, t),
x*=0;
break,
x+=t)
);
if(x,
t0=!(x%2);
x++;
x+=t0);
t=ispower(x, , &z);
if(t&&z==2,
return(B)
)
);
return(0)
}
```