login
Numbers >= 10 that are divisible by the sum and difference of their digits.
1

%I #27 Sep 08 2022 08:46:05

%S 10,12,20,21,24,30,36,40,42,45,48,50,54,60,63,70,80,84,90,100,102,111,

%T 112,120,126,132,195,200,201,204,210,222,224,225,230,240,264,270,300,

%U 306,315,320,322,324,333,336,342,351,360,364,372,392,396,400

%N Numbers >= 10 that are divisible by the sum and difference of their digits.

%C 3-digit numbers abc must be divisible by a+b+c and a-b-c.

%C 4-digit numbers abcd must be divisible by a+b+c+d and a-b-c-d, ....

%H Derek Orr, <a href="/A225742/b225742.txt">Table of n, a(n) for n = 1..10000</a>

%e 102 is a term because 102 is divisible by 1+0+2 and it is divisible by 1-0-2.

%p filter:= proc(n)

%p local A,s,d;

%p A:= convert(n,base,10);

%p s:= convert(A,`+`);

%p d:= 2*A[1]-s;

%p d <> 0 and n mod s = 0 and n mod d = 0;

%p end proc:

%p select(filter, [$10 .. 1000]); # _Robert Israel_, Aug 12 2014

%o (Magma) [n: n in [10..500] | not IsZero(u) and IsDivisibleBy(n,&+t) and IsDivisibleBy(n,u) where u is 2*t[#t]-&+t where t is Intseq(n)]; // _Bruno Berselli_, Aug 13 2013

%o (PARI)

%o for(n=10,10^3,d=digits(n);if(sumdigits(n)!=2*d[1],if(n%sumdigits(n)==0&&n%(sumdigits(n)-2*d[1])==0,print1(n,", ")))) \\ _Derek Orr_, Aug 12 2014

%K nonn,base,easy

%O 1,1

%A _Derek Orr_, Aug 04 2013