Homepage Solution manuals Ivan Niven An Introduction to the Theory of Numbers Exercise 4.4.12 (Number of ways of writing $n$ in the form $n = m_1 + m_2 + \cdots + m_k$)

Exercise 4.4.12 (Number of ways of writing $n$ in the form $n = m_1 + m_2 + \cdots + m_k$)

Let r ( n ) be the number of ways of writing a positive integer n in the form n = m 1 + m 2 + + m k where m 1 , m 2 , , m k and k are arbitrary positive integers. Show that r ( n ) = 1 + r ( 1 ) + r ( 2 ) + + r ( n 1 ) for n 2 . Deduce that r ( n ) = 2 r ( n 1 ) for n 2 . Conclude that r ( n ) = 2 n 1 for all positive integers n .

Answers

Note that here the order of ( m 1 , m 2 , , m k ) is relevant (if not, we obtain the number p ( n ) of partitions of n , which is another problem of Number Theory). So ( 1 , 3 , 1 ) and ( 3 , 1 , 1 ) are two distinct decompositions of n .

Proof. Let n be a positive integer. We search the cardinality of A , where A is the set of tuples ( m 1 , m 2 , , m k ) such that n = m 1 + m 2 + + m k .

Suppose that n 2 . Consider the sets A i A of such tuples ( m 1 , m 2 , , m k ) of positive integers satisfying m 1 = i . Since n = m 1 + m 2 + + m k , we have 1 m 1 n , thus A = j = 1 n A j (disjoint union). So

r ( n ) = | A | = j = 1 n | A j | .

If i = n , there is a unique tuple ( n ) satisfying the condition, so | A 1 | = 1 .

More generally, if 1 i n 1 , the cardinality of A n i is equal to the number of tuples m 2 , , m k such that m 2 + + m k = i , where k 2 is arbitrary, thus

| A n i | = r ( i ) .

Therefore

| A | = j = 1 n | A j | = | A n | + j = 1 n 1 | A j | = 1 + i = 1 n 1 | A n i | ( i = n j ) = 1 + i = 1 n 1 r ( i ) .

So

r ( n ) = 1 + r ( 1 ) + r ( 2 ) + + r ( n 1 ) ( n 2 ) .

Then for all n 3 ,

r ( n ) r ( n 1 ) = ( 1 + i = 1 n 1 r ( i ) ) ( 1 + i = 1 n 2 r ( i ) ) = r ( n 1 ) .

Therefore r ( n ) = 2 r ( n 1 ) for n 3 . Note that r ( 1 ) = 1 , and r ( 2 ) = 1 + r ( 1 ) = 2 , so for every n 2 ,

r ( n ) = 2 r ( n 1 ) .

By induction, we obtain

r ( n ) = 2 n 1 r ( 1 ) .

Since r ( 1 ) = 1 ,

r ( n ) = 2 n 1 .

Note: Following the preceding algorithm to find A i , I give a recursive python program to obtain all decompositions of n :

def decomposition(n):
    if n == 1:
        return [[1]]
    else:
        dec = [[n]]
        for i in range(1,n):
            for l in decomposition(n-i):
                dec.append([i] + l)
        return dec

decomposition(5)
[[5],
 [1, 4],
 [1, 1, 3],
 [1, 1, 1, 2],
 [1, 1, 1, 1, 1],
 [1, 1, 2, 1],
 [1, 2, 2],
 [1, 2, 1, 1],
 [1, 3, 1],
 [2, 3],
 [2, 1, 2],
 [2, 1, 1, 1],
 [2, 2, 1],
 [3, 2],
 [3, 1, 1],
 [4, 1]]
 

User profile picture
2025-02-11 10:17
Comments