%I #35 Dec 01 2016 01:32:12
%S 5,19,3,7,82811,3,11,17,3,191,5,3,37,29,3,5,69431799799,3,1105589,
%T 28463,3,431,2947308589,3,7,5,3,59,11,3,5,7,3,41
%N a(n) is the smallest odd prime that divides (-n) + the sum of all smaller primes, or 0 if no such prime exists.
%C From _Robert G. Wilson v_, Nov 15 2016: (Start)
%C If n == 2 (mod 3) then a(n) = 3;
%C If n == 0 (mod 5) then a(n) = 5;
%C If n == 3 (mod 7) then a(n) = 7;
%C If n == 6 (mod 11) then a(n) = 11;
%C If n == 2 (mod 13) then a(n) = 13;
%C If n == 7 (mod 17) then a(n) = 17;
%C If n == 1 (mod 19) then a(n) = 19;
%C If n == 8 (mod 23) then a(n) = 23;
%C in that order; i.e., from smaller to greater prime modulus, etc.
%C First occurrence of p>2: 2, 0, 3, 6, 54, 7, 1, 123, 13, 36, 12, 33, 453, 46, ..., .
%C (End)
%C The congruence classes in the above list, modulo the prime bases, namely 2, 0, 3, 6, 2, ..., are given by A071089, in which each term is the remainder when the sum of the first n primes is divided by the n-th prime. - _Neil Fernandez_, Nov 23 2016
%H Robert G. Wilson v, <a href="/A274995/a274995.txt">n and a(n), or 0 if no such value is known, for n=0..10000</a>
%e a(1) = 19 because 19 is the smallest odd prime that divides the sum of (-1) + (sum of all primes smaller than itself), that is, -1 + 58 = 57.
%e a(7) = 17 because -7 + 2 + 3 + 5 + 7 + 11 + 13 + 17 = 49 and 49/7 = 7.
%t f[n_] := Block[{p = 3, s = 2 - n}, While[ Mod[s, p] != 0, s = s + p; p = NextPrime@ p]; p]; Array[f, 16, 0] (* _Robert G. Wilson v_, Nov 15 2016 *)
%o (PARI) sump(n) = s = 0; forprime(p=2, n-1, s+=p); s;
%o a(n) = {my(p=3); while ((sump(p)-n) % p, p = nextprime(p+1)); p;} \\ _Michel Marcus_, Nov 12 2016
%o (PARI) a(n)=my(s=2); forprime(p=3,, if((s-n)%p==0, return(p)); s+=p) \\ _Charles R Greathouse IV_, Nov 15 2016
%Y Cf. A007504, A007506, A071089, A274649.
%K nonn,more
%O 0,1
%A _Neil Fernandez_, Nov 11 2016
%E a(16)-a(33) from _Charles R Greathouse IV_, Nov 15 2016
|