login
A065794
Numbers n such that the sum of all possible subsequences of the digits in n, excluding n itself, sums to n.
2
257982, 258564, 259146, 265707, 266193, 272754, 273336, 280383, 2176722, 2181960, 2309670, 2315448, 2320686, 4642524, 20096887, 20096935, 20097375, 20097423, 20206495, 20206543, 20207031, 40365992, 40366480, 40424038, 41102597, 41102645, 41103085
OFFSET
1,1
COMMENTS
The b-file lists all the terms in this finite sequence.
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
LINKS
Vadim Sheviakov, list of all 52 terms
EXAMPLE
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.
MATHEMATICA
okQ[n_] := Module[{d=IntegerDigits[n]}, Total[FromDigits /@ Subsets[d]] == 2 n]; Reap[Do[If[okQ[n], Sow[n]], {n, 300000}]][[2, 1]]
PROG
(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
(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
(Delphi) procedure TForm1.Button1Click(Sender: TObject);
var
i, j, jj, k, l, n, m, t:longint;
s:string;
a:array of longint;
begin
n:=UpDown1.Position;
SetLength(a, n);
for i:=0 to n-1 do a[i]:=0;
t:=1;
for i:=0 to n-1 do begin
for j:=1 to trunc(power(2, n))-2 do begin
s:=IntToStr(t+trunc(power(10, n))); delete(s, 1, 1); l:=0; jj:=j;
for k:=1 to n do begin
if jj mod 2 = 1 then begin
delete(s, k-l, 1);
l:=l+1;
end;
jj:=jj div 2;
end;
a[i]:=a[i]+StrToInt(s);
end;
t:=10*t;
end;
for i:=t div 10 to t-1 do begin
m:=i; k:=0;
for j:=0 to n-1 do begin
k:=k+(m mod 10)*a[j];
m:=m div 10;
end;
if i=k then Edit1.Text:=Edit1.Text+IntToStr(k)+' ';
end;
end; // Vadim Sheviakov, Jul 05 2011
(Python)
from itertools import combinations
def ok(n):
s, ss = str(n), 0
for d in range(len(s)-1, 0, -1):
for c in combinations(s, d):
t = int("".join(c))
ss += t
if ss > n:
return False
return n and ss == n
print([k for k in range(300000) if ok(k)]) # Michael S. Branicky, Nov 08 2022
CROSSREFS
Cf. A153980 (when the integers formed appear only once).
Sequence in context: A105657 A251883 A251165 * A206253 A157670 A252921
KEYWORD
base,nonn,fini,full
AUTHOR
Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Nov 19 2001
EXTENSIONS
a(15)-a(28) from Donovan Johnson, Jan 19 2011
a(29)-a(52) from Vadim Sheviakov, Jul 05 2011
STATUS
approved