%I #49 May 04 2021 09:01:49
%S 5,3,30915397,11339869,3,5,859,3,41,233,3,7,4175194313,3,307,5,3,1459,
%T 7,3,5,9907,3,647,13,3,31,11,3,193,5,3,7,2939,3,5,3167,3,11,7,3,1321,
%U 86629,3,17,5,3
%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 _David A. Corneth_, Nov 12 2016: (Start)
%C a(n) is the smallest odd prime p such that p|(n + A007504(primepi(p) - 1)) or zero if no such p exists.
%C If a(n) = p then a(n + p) <= p. (End)
%C If n is congruent to 1 (mod 3), then a(n)=3.
%C a(2), a(3) and a(12) were found by _Jack Brennen_.
%C From _Robert G. Wilson v_, Nov 13 2016: (Start)
%C If n == 1 (mod 3) then a(n) = 3;
%C If n == 0 (mod 5) then a(n) = 5;
%C If n == 4 (mod 7) then a(n) = 7;
%C if n == 5 (mod 11) then a(n) = 11;
%C if n == 11 (mod 13) then a(n) = 13;
%C if n == 10 (mod 17) then a(n) = 17;
%C if n == 18 (mod 19) then a(n) = 19;
%C if n == 23 (mod 23) then a(n) = 23;
%C in that order, i.e., from smallest to greatest prime modulus, etc.
%C First occurrence of p > 2: 1, 0, 11, 27, 24, 44, 56, 84, 161, ..., .
%C a(47) > 10^11. (End)
%H Michael S. Branicky, <a href="/A274649/a274649_1.txt">Alternate Python program</a>.
%H Michael S. Branicky, <a href="/A274649/a274649_2.txt">n and a(n) for n = 0..10000 or 0 of no such value is known, search limit = 9*10^9.</a>
%H Robert G. Wilson v, <a href="/A274649/a274649.txt">n and a(n) for n = 0..10000 or 0 if no such value is known.</a>
%e a(6) = 859 because 859 is the smallest odd prime that divides the sum of 6 + (sum of all primes smaller than itself).
%e a(8) = 41 because 8+2+3+5+7+11+13+17+19+23+29+31+37+41 = 246 and 246/41 = 6.
%t f[n_] := Block[{p = 3, s = n +2}, While[ Mod[s, p] != 0, s = s + p; p = NextPrime@ p]; p]; Array[f, 47, 0] (* _Robert G. Wilson v_, Nov 12 2016 *)
%o (Python) # see link for an alternate that searches in parallel to a limit
%o from sympy import nextprime
%o def a(n):
%o psum, p = 2, 3
%o while (n + psum)%p: psum, p = psum + p, nextprime(p)
%o return p
%o for n in range(12):
%o print(a(n), end=", ") # _Michael S. Branicky_, May 03 2021
%Y Cf. A007504, A007506, A024011, A274995.
%Y Cf. A016777 (n==1 (mod 3))
%K nonn,more
%O 0,1
%A _Neil Fernandez_, Nov 10 2016