OFFSET
1,4
COMMENTS
a(n) = 1 iff n is a prime or a pseudoprime (odd or even) to base 2.
We have a(n) <= n - phi(n) and a(n) <= phi(n), so a(n) <= n/2.
From Robert Israel, Mar 11 2016: (Start)
If n is odd, a(n) = n mod A002326((n-1)/2).
a(n) >= A007814(n).
a(p^k) = p^(k-1) for all k >= 1 and all odd primes p not in A001220.
Conjecture: a(n) <= n/3 for all n > 8. (End)
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
a(n) < n/2 for n > 4.
a(2^k) = k for all k >= 0.
a(2*p) = 2 for all primes p.
MAPLE
f:= proc(n) local d, b, t, m, c;
d:= padic:-ordp(n, 2);
b:= n/2^d;
t:= 2 &^ n mod n;
m:= numtheory:-mlog(t, 2, b, c);
if m < d then m:= m + c*ceil((d-m)/c) fi;
m
end proc:
f(1):= 0:
map(f, [$1..1000]; # Robert Israel, Mar 11 2016
MATHEMATICA
Table[k = 0; While[PowerMod[2, n, n] != PowerMod[2, k, n], k++]; k, {n, 120}] (* Michael De Vlieger, Mar 15 2016 *)
PROG
(PARI) a(n) = {my(m = 0); while (Mod(2, n)^m != 2^n, m++); m; } \\ Altug Alkan, Sep 23 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Mar 11 2016
EXTENSIONS
More terms from Michel Marcus, Mar 11 2016
STATUS
approved