login
a(n) = n-th prime modulo 3.
28

%I #64 Mar 26 2022 14:55:01

%S 2,0,2,1,2,1,2,1,2,2,1,1,2,1,2,2,2,1,1,2,1,1,2,2,1,2,1,2,1,2,1,2,2,1,

%T 2,1,1,1,2,2,2,1,2,1,2,1,1,1,2,1,2,2,1,2,2,2,2,1,1,2,1,2,1,2,1,2,1,1,

%U 2,1,2,2,1,1,1,2,2,1,2,1,2,1,2,1,1,2,2,1,2,1,2,2,1,2,1,2,2,2,1,1,1,2,2,2,1

%N a(n) = n-th prime modulo 3.

%C If n > 2 and prime(n) is a Mersenne prime then a(n) = 1. Proof: prime(n) = 2^p - 1 for some odd prime p, so prime(n) = 2*4^((p-1)/2) - 1 == 2 - 1 = 1 (mod 3). - _Santi Spadaro_, May 03 2002; corrected and simplified by _Dean Hickerson_, Apr 20 2003

%C Except for n = 2, a(n) is the smallest number k > 0 such that 3 divides prime(n)^k - 1. - _T. D. Noe_, Apr 17 2003

%C a(n) <> 0 for n <> 2; a(A049084(A003627(n))) = 2; a(A049084(A002476(n))) = 1; A134323(n) = (1 - 0^a(n)) * (-1)^(a(n)+1). - _Reinhard Zumkeller_, Oct 21 2007

%C Probability of finding 1 (or 2) in this sequence is 1/2. This follows from the Prime Number Theorem in arithmetic progressions. Examples: There are 4995 1's in terms (10^9 +1) to (10^9+10^4); there are 10^9/2-1926 1's in the first 10^9 terms. - _Jerzy R Borysowicz_, Mar 06 2022

%H Nathaniel Johnston, <a href="/A039701/b039701.txt">Table of n, a(n) for n = 1..10000</a>

%p seq(ithprime(n) mod 3, n=1..105); # _Nathaniel Johnston_, Jun 29 2011

%t Table[Mod[Prime[n], 3], {n, 100}]

%o (Haskell)

%o a039701 = (`mod` 3) . a000040

%o a039701_list = map (`mod` 3) a000040_list

%o -- _Reinhard Zumkeller_, Nov 16 2012

%o (Magma) [p mod(3): p in PrimesUpTo(500)]; // _Vincenzo Librandi_, May 06 2014

%o (PARI) primes(100)%3 \\ _Charles R Greathouse IV_, May 06 2014

%Y Cf. A091178 (indices of 1's), A091177 (indices of 2's).

%Y Cf. A120326 (partial sums).

%Y Cf. A185934, A217659.

%Y Other moduli: A039702-A039706, A038194, A007652, A039709-A039715.

%K nonn,easy

%O 1,1

%A _Clark Kimberling_