%I #35 Jul 19 2023 12:30:54
%S 2,3,5,7,11,19,41,71,101,109,113,151,191,199,223,229,307,401,409,449,
%T 593,701,881,911,1009,1013,1091,1129,1231,1301,1303,1451,1559,1811,
%U 1999,2029,2089,2213,2281,2311,2351,2399,2531,2609,2711,2753,3037,3079,3109,3221,3251,3329
%N Primes p for which p-1 and p+1 are Niven numbers.
%C All of the prime numbers in sequences A253213, A199684, A199687 are part of the sequence.
%H Marius A. Burtea, <a href="/A320771/b320771.txt">Table of n, a(n) for n = 1..11188</a>
%e For p = 11, p-1 = 10 and p + 1 = 12. 10 is divisible by 1 = 1 + 0, 12 is divisible by 3 = 1 + 2. Thus, p = 11 is a term.
%e For p = 229, p-1 = 228 and p + 1 = 230. 228 is divisible by 12 = 2 + 2 + 8, and 230 is divisible by 5 = 2 + 3 + 0. Thus, p = 229 is a term.
%t nivenQ[n_] := Divisible[n, Total[IntegerDigits[n]]]; Select[Range[10000], PrimeQ[#] && nivenQ[#-1] && nivenQ[#+1] &] (* _Amiram Eldar_, Oct 31 2018 *)
%t nnQ[p_]:=Divisible[p,Total[IntegerDigits[p]]]; Select[Prime[Range[500]],AllTrue[#+{1,-1},nnQ]&] (* _Harvey P. Dale_, Jul 19 2023 *)
%o (PARI) isniven(n) = frac(n/sumdigits(n)) == 0;
%o isok(p) = isprime(p) && isniven(p-1) && isniven(p+1); \\ _Michel Marcus_, Oct 22 2018
%o (GAP) Filtered([2..2400],p->IsPrime(p) and (p-1) mod List(List([1..p-1],ListOfDigits),Sum)[p-1]=0 and (p+1) mod List(List([1..p+1],ListOfDigits),Sum)[p+1]=0); # _Muniru A Asiru_, Oct 29 2018
%o (Magma) [p: p in PrimesUpTo(2000) | IsIntegral((p-1)/&+Intseq(p-1)) and IsIntegral((p+1)/&+Intseq(p+1))]; // _Marius A. Burtea_, Jan 06 2019
%Y Cf. A000040, A005349, A007953, A253213, A177506, A199684, A199687.
%K nonn,base
%O 1,1
%A _Marius A. Burtea_, Oct 21 2018
|