forked from yunghsianglu/CProgramExercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq1
More file actions
38 lines (30 loc) · 1.48 KB
/
Copy pathq1
File metadata and controls
38 lines (30 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
For a given positive integer, we want to partition it into the sum of
some positive integers, or itself. For example, 1 to 4 can be
partitioned as
1 = 1 2 = 1 + 1 3 = 1 + 1 + 1 4 = 1 + 1 + 1 + 1
= 2 = 1 + 2 = 1 + 1 + 2
= 2 + 1 = 1 + 2 + 1
= 3 = 1 + 3
= 2 + 1 + 1
= 2 + 2
= 3 + 1
= 4
By observation, there is
one way to partition 1.
two ways to partition 2.
four ways to partition 3.
eight ways to partition 4.
In general, there are exp2(n-1) ways to partition value n.
In the above examples,
when partitioning 1, "3" is not used.
when partitioning 2, "3" is not used.
when partitioning 3, "3" is used once.
when partitioning 4, "3" is used twice.
When partitioning value n (n > 4), how many times is "3" used?
The answer is not exp2(n-2). You can use the following table to
validate your formula. If your formula does not match these cases,
the formula is definitely wrong. However, matching these cases does
not mean your formula is correct. You must have a systematic way to
find the formula. Do not try to find a formula to match these values.
n 4 5 6 7 8 9
f(n) 2 5 12 28 64 144