%I #30 Dec 29 2022 11:03:35
%S 257982,258564,259146,265707,266193,272754,273336,280383,2176722,
%T 2181960,2309670,2315448,2320686,4642524,20096887,20096935,20097375,
%U 20097423,20206495,20206543,20207031,40365992,40366480,40424038,41102597,41102645,41103085
%N Numbers n such that the sum of all possible subsequences of the digits in n, excluding n itself, sums to n.
%C The b-file lists all the terms in this finite sequence.
%C Here, subsequence means a subset of the digits, keeping the original order of the digits. Hence, 89 does not appear in the sum for a(1) in the example. - _Michael S. Branicky_, Nov 08 2022
%H Vadim Sheviakov, <a href="/A065794/b065794.txt">list of all 52 terms</a>
%e a(1) = 257982 because the sum of all proper subsets of 257982 equals 2 + 8 + 82 + 9 + 92 + 98 + 982 + 7 + 72 + 78 + 782 + 79 + 792 + 798 + 7982 + 5 + 52 + 58 + 582 + 59 + 592 + 598 + 5982 + 57 + 572 + 578 + 5782 + 579 + 5792 + 5798 + 57982 + 2 + 22 + 28 + 282 + 29 + 292 + 298 + 2982 + 27 + 272 + 278 + 2782 + 279 + 2792 + 2798 + 27982 + 25 + 252 + 258 + 2582 + 259 + 2592 + 2598 + 25982 + 257 + 2572 + 2578 + 25782 + 2579 + 25792 + 25798 = 257982.
%t okQ[n_] := Module[{d=IntegerDigits[n]}, Total[FromDigits /@ Subsets[d]] == 2 n]; Reap[Do[If[okQ[n], Sow[n]], {n,300000}]][[2, 1]]
%o (PARI) /* finds 8 digit terms */ for(n=10^7, 10^8-1, d8=Str(n-n\10*10); d7=Str((n-n\100*100)\10); d6=Str((n-n\1000*1000)\100); d5=Str((n-n\10^4*10^4)\1000); d4=Str((n-n\10^5*10^5)\10^4); d3=Str((n-n\10^6*10^6)\10^5); d2=Str((n-n\10^7*10^7)\10^6); d1=Str((n-n\10^8*10^8)\10^7); s=0-n; for(i1=0, 1, for(i2=0, 1, for(i3=0, 1, for(i4=0, 1, for(i5=0, 1, for(i6=0, 1, for(i7=0, 1, for(i8=0, 1, c=""; if(i1, c=concat(c, d1)); if(i2, c=concat(c, d2)); if(i3, c=concat(c, d3)); if(i4, c=concat(c, d4)); if(i5, c=concat(c, d5)); if(i6, c=concat(c, d6)); if(i7, c=concat(c, d7)); if(i8, c=concat(c, d8)); s=s+eval(c))))))))); if(n==s, print(n))) \\ _Donovan Johnson_, Jan 19 2011
%o (PARI) isok(k) = my(d=digits(k), ss=0); forsubset(#d, s, if (#s && (#s < #d), ss += fromdigits(vector(#s, i, d[s[i]])); if (ss > k, return(0)););); ss == k; \\ _Michel Marcus_, Nov 08 2022
%o (Delphi) procedure TForm1.Button1Click(Sender: TObject);
%o var
%o i,j,jj,k,l,n,m,t:longint;
%o s:string;
%o a:array of longint;
%o begin
%o n:=UpDown1.Position;
%o SetLength(a,n);
%o for i:=0 to n-1 do a[i]:=0;
%o t:=1;
%o for i:=0 to n-1 do begin
%o for j:=1 to trunc(power(2,n))-2 do begin
%o s:=IntToStr(t+trunc(power(10,n))); delete(s,1,1); l:=0; jj:=j;
%o for k:=1 to n do begin
%o if jj mod 2 = 1 then begin
%o delete(s,k-l,1);
%o l:=l+1;
%o end;
%o jj:=jj div 2;
%o end;
%o a[i]:=a[i]+StrToInt(s);
%o end;
%o t:=10*t;
%o end;
%o for i:=t div 10 to t-1 do begin
%o m:=i; k:=0;
%o for j:=0 to n-1 do begin
%o k:=k+(m mod 10)*a[j];
%o m:=m div 10;
%o end;
%o if i=k then Edit1.Text:=Edit1.Text+IntToStr(k)+' ';
%o end;
%o end; // _Vadim Sheviakov_, Jul 05 2011
%o (Python)
%o from itertools import combinations
%o def ok(n):
%o s, ss = str(n), 0
%o for d in range(len(s)-1, 0, -1):
%o for c in combinations(s, d):
%o t = int("".join(c))
%o ss += t
%o if ss > n:
%o return False
%o return n and ss == n
%o print([k for k in range(300000) if ok(k)]) # _Michael S. Branicky_, Nov 08 2022
%Y Cf. A153980 (when the integers formed appear only once).
%K base,nonn,fini,full
%O 1,1
%A Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Nov 19 2001
%E a(15)-a(28) from _Donovan Johnson_, Jan 19 2011
%E a(29)-a(52) from _Vadim Sheviakov_, Jul 05 2011