OFFSET
1,2
COMMENTS
This is called the discriminator of f(x)=x^3+x.
First differs from A064235 at n=244.
LINKS
Michel Marcus, Table of n, a(n) for n = 1..1000
Quan-Hui Yang and Lilu Zhao, On a discriminator for the polynomial f(x)=x^3+x, arXiv:2111.11227 [math.NT], 2021.
FORMULA
a(n) = 7*3^(6s+4) if n=3^(6s+5)+1 or n=3^(6s+5)+2; otherwise a(n) = 3^ceiling(log_3(n)) (see Theorem 1.1 in Yang & Zhao).
MATHEMATICA
a[n_] := Module[{e1 = IntegerExponent[n-1, 3], e2 = IntegerExponent[n-2, 3], e = -1}, If[3^e1 == n - 1 && Mod[e1, 6] == 5, e = e1 - 1]; If[3^e2 == n-2 && Mod[e2, 6] == 5, e = e2 - 1]; If[e > -1, 7*3^e, 3^Ceiling[Log[3, n]]]]; Array[a, 100] (* Amiram Eldar, Nov 24 2021 *)
PROG
(PARI) isok(n, m) = my(v=vector(n, k, (k^3+k)% m)); #v == #vecsort(v, , 8);
a(n) = my(m=1); while (!isok(n, m), m++); m;
(PARI) a(n) = {my(v); if ((n%3 == 1) && (n!=1), v=valuation(n-1, 3); if ((3^v == n-1) && ((v%6)==5), return(7*3^(v-1)))); if ((n%3 == 2) && (n!=2), v=valuation(n-2, 3); if ((3^v == n-2) && ((v%6)==5), return(7*3^(v-1)))); return(3^ceil(log(n)/log(3))); }
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Michel Marcus, Nov 24 2021
STATUS
approved