Let S be a set of some positive integers.
We'll call S autonomous if the number of elements in S is itself an element of S. e.g. the set {2,3,5} is autonomous, as is the set {2,7}, but the sets {1, 4} or {2,4,5} are not.
Determine a general formula for the number
of autonomous subsets of {1, 2, 3, ... , n}.
Let f(n) be the sought function of n.
f(1) = 0
f(2) = 1 {2}
f(3) = 3 {2}{3}{1,3}
f(4) = 7 {2}{3}{4}{1,3}{1,4}{3,4}{1,2,4}
f(n) = Sigma{i=1 to n-1} C(n-1,i)
10 for N=2 to 12
15 T=0
20 for I=1 to N-1
30 T=T+combi(N-1,I)
40 next
50 print N,T
60 next
finds
2 1
3 3
4 7
5 15
6 31
7 63
8 127
9 255
10 511
11 1023
12 2047
f(n) = 2^(n-1) - 1
|
Posted by Charlie
on 2014-07-29 14:38:40 |