| Ruud H.G. van Tol on Wed, 16 Nov 2022 16:22:16 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| A306044(n) |
I added PARI-code to https://oeis.org/A306044
"Powers of 2, 3 and 5."
but I'm not happy with it.
{
a(n)=
my(f= [2, 3, 5]); /* ordered co-primes (?) */
for(i= 1, #f
, my(p= (n-1)\f[i], d= -1, j= 0, m= 0);
while( j < n
, d++;
m= f[i] ^ (p+d);
j= 1; for(k=1, #f, j+= logint(m, f[k])); /* j= index */
if( (j > n) && 0 == d, j=0; p--; d=-1) /* retry */
);
if(j==n, return(m)) /* found */
)
}
The initial value of 'p' is a (simple) guess.
In case it overshoots, there is a backtracking p-- later.
Please let me know if there is a better way to initialize 'p'.
Or a better way to do all of this together!
-- Thanks, Ruud