Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A257531
If 2^(n-1) mod n = 1, then 1 else 0.
3
0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0
OFFSET
1
COMMENTS
This first differs from A010051 (1 if n is prime, else 0) at the second term. The next position differing from A010051 is at the 341st term, and further divergences appear for odd pseudoprimes to base 2 (A001567).
EXAMPLE
a(341) = 1 as 2^340 mod 341 is 1.
MAPLE
[0, seq(`if`(2 &^ (n-1) mod n = 1, 1, 0), n = 2..104)]; # Peter Luschny, Sep 19 2017
MATHEMATICA
f[n_] := If[PowerMod[2, n - 1, n] == 1, 1, 0]; Array[f, 105] (* Robert G. Wilson v, Apr 28 2015 *)
PROG
(PARI) A257531(n) = if(n==1, 0, if(Mod(2, n)^(n-1)==1, 1, 0)); \\ Antti Karttunen, Michel Marcus & Altug Alkan, Sep 13-20 2017
CROSSREFS
Characteristic function for A176997 (without its initial 1).
Sequence in context: A072629 A164292 A337802 * A151763 A353558 A353638
KEYWORD
nonn
AUTHOR
Gerald Hillier, Apr 28 2015
STATUS
approved