login
Primes p where the difference between the largest digit of p and sum of all other digits equals 4.
1

%I #16 Feb 18 2017 02:40:52

%S 37,59,73,127,149,239,271,293,307,419,491,509,941,1049,1061,1117,1171,

%T 1193,1229,1319,1409,1601,1913,1931,2017,2039,2129,2309,2903,3119,

%U 3191,3209,3911,4019,4091,5009,6011,6101,9041,9203,9221,9311,10061,10139,10193

%N Primes p where the difference between the largest digit of p and sum of all other digits equals 4.

%H Charles R Greathouse IV, <a href="/A281290/b281290.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..2579 from Lars Blomberg)

%e 37 is a term since 7 - 3 = 4.

%e 9221 is a term, since 9 - (2 + 2 + 1) = 4.

%t Select[Prime@ Range[10^3], Fold[#1 - #2 &, First@ #, Rest@ #] == 4 &@ Reverse@ Sort@ IntegerDigits@ # &] (* _Michael De Vlieger_, Feb 08 2017 *)

%o (PARI) is(n)=my(d=digits(n)); 2*vecmax(d)==vecsum(d)+4 && isprime(n) \\ _Charles R Greathouse IV_, Feb 18 2017

%o (PARI) do(d)=my(v=List()); for(len=1,d, for(b=5,9, for(e=0,len-1, my(t=b*10^e,n,dig); forvec(u=vector(b-4,i,[0,len-1]), n=t+sum(i=1,#u,10^u[i]); if(!isprime(n), next); dig=digits(n); if(2*vecmax(dig)==vecsum(dig)+4, listput(v,n)), 1)))); Set(v) \\ _Charles R Greathouse IV_, Feb 18 2017

%Y A subsequence of A280915.

%Y Cf. A000040.

%K nonn,base

%O 1,1

%A _Osama Abuajamieh_, Jan 19 2017

%E More terms from _Lars Blomberg_, Feb 18 2017