%I #30 Jun 17 2022 03:23:22
%S 1,2,3,5,7,11,14,21,27,38,52,73,90,123,159,211,263,344,413,535,658,
%T 832,1026,1276,1499,1846,2226,2708,3229,3912,4592,5541,6495,7795,9207,
%U 10908,12547,14852,17358,20493,23709,27744,31921,37250,43013,49936,57319,66318
%N Number of nondividing sets on {1,2,...,n}.
%C A set is called nondividing if no element divides the sum of any nonempty subset of the other elements.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/NondividingSet.html">Nondividing Set</a>
%e a(5) = 11 because there are 11 nondividing subsets of {1,2,3,4,5}: {}, {1}, {2}, {3}, {4}, {5}, {2,3}, {2,5}, {3,4}, {3,5}, {4,5}.
%e a(7) = 21: {}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {2,3}, {2,5}, {2,7}, {3,4}, {3,5}, {3,7}, {4,5}, {4,6}, {4,7}, {5,6}, {5,7}, {6,7}, {4,6,7}.
%p sums:= proc(s) option remember; local i, m;
%p m:= max(s[]);
%p `if`(m<1, {}, {m, seq([i,i+m][], i=sums(s minus {m}))})
%p end:
%p b:= proc(i,s) option remember; local j, ok, t, si;
%p if i<2 then 1
%p else si:= s union {i};
%p ok:= true;
%p for j in sums(si) while ok do
%p for t in si while ok do
%p if irem(j, t)=0 and t<>j then ok:= false fi
%p od
%p od;
%p b(i-1,s) +`if`(ok, b(i-1, si), 0)
%p fi
%p end:
%p a:= n-> `if`(n=0, 1, 1+b(n, {})):
%p seq(a(n), n=0..25); # _Alois P. Heinz_, Mar 08 2011
%t sums[s_] := sums[s] = Module[{m=Max[s]},
%t If[m<1, {},
%t Join[{m},
%t Sequence@@Table[{i,i+m}, {i,sums[DeleteCases[s,m]]}]]]
%t ];
%t b[i_,s_] := b[i,s] = Module[{ ok,si,sij,sik},
%t If[ i<2, 1, si = Union[s,{i}];
%t ok = True;
%t For[j=1, j <= Length[sums[si]] && ok, j++,
%t sij = sums[si][[j]];
%t For[k=1, k <= Length[si] && ok, k++,
%t If[Divisible[sij,sik=si[[k]]]&&sij!=sik,ok=False]]];
%t b[i-1, s] + If[ok, b[i-1,si],0]
%t ]
%t ];
%t a[n_] := a[n] = If[n==0, 1, 1+b[n, {}]];
%t Table[ Print[ a[n] ]; a[n], {n,0,47}]
%t (* _Jean-François Alcover_, Oct 10 2012, after _Alois P. Heinz_ *)
%Y Row sums of A187489. Cf. A068063.
%K nonn,nice
%O 0,2
%A _Eric W. Weisstein_
%E More terms from _David Wasserman_, Feb 15 2002
%E a(41)-a(47) from _Alois P. Heinz_, Mar 08 2011
|