%I
%S 20,24,25,27,29,30,33,34,35,37,38,42,43,45,47,49,50,52,53,54,56,57,59,
%T 65,67,70,72,73,74,75,76,78,79,83,87,92,94,95,97,101,102,104,106,110,
%U 111,112,113,114,115,116,117,118,119,120,121,125,126,128,131,133,140
%N Numbers such that the (positive) difference between the sum of the digits and the product of the digits is a prime number.
%H Robert Israel, <a href="/A117737/b117737.txt">Table of n, a(n) for n = 1..10000</a>
%e 97 is in the sequence because the sum of its digits is 16, the product of its digits is 63 and the difference between 16 and 63 is 47, which is a prime.
%p filter:= proc(n) local L;
%p L:= convert(n,base,10);
%p isprime(abs(convert(L,`+`)convert(L,`*`)))
%p end proc:
%p select(filter, [$1..1000]); # _Robert Israel_, Jan 22 2019
%t Select[Range[140],PrimeQ[Abs[Plus@@(x=IntegerDigits[#])Times@@x]]&] (* _Jayanta Basu_, May 18 2013 *)
%o (PARI) sudig(i,suOrmul)= { local(nshft,resul) ; nshft = i ; resul = nshft % 10 ; nshft = nshft \ 10 ; while(nshft>0, if(suOrmul==0, resul += nshft % 10, resul *= nshft % 10 ) ; nshft \= 10 ; ) ; return(resul) ; } { for(n=10,150, summ = sudig(n,0) ; mull = sudig(n,1) ; if( isprime(summmull), print1(n,",") ) ; ) ; } \\ _R. J. Mathar_, Apr 21 2006
%Y Cf. A000040.
%K base,nonn
%O 1,1
%A Luc Stevens (lms022(AT)yahoo.com), Apr 14 2006
%E More terms from _R. J. Mathar_, Apr 21 2006
