Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
INVESTIGATING PATTERNS IN THE FORMATION OF WEAKLY COMPLETE NUMBER SEQUENCES Michael D. Paul Loyola College in Maryland, Mathematical Sciences ’10 Advisor Dr. Michael Knapp Department of Mathematical Sciences Loyola College in Maryland Sponsored by the Hauber Fellowship Fund Loyola College in Maryland Summer 2008 Abstract This research focused on finding how to determine the terms of a weakly complete sequence with a given set of initial terms. For the sequences beginning with {1, n,...}, {n, n + 1,...}, or {n, 2n,...} for most values of n, specific formulae to determine the next terms of these sequences were found and proven. A conjecture formula for the terms of the sequence beginning with {n, n + m} has also been found, but has yet to be proven. Background A sequence of numbers is considered complete if every natural number can be written as a sum of distinct terms of the sequence. Perhaps the most famous example of a complete sequence is the Fibonacci sequence, {1, 1, 2, 3, 5, 8, 13, 21, 34,...}1. Any positive integer can be obtained by adding any combination of numbers in this sequence; for example, 17 = 13 + 3 + 1 and 33 = 21 + 8 + 3 + 1. A sequence is considered to be weakly complete if every integer greater than a given natural number (called the threshold of completeness) can be written as a sum of distinct terms of the sequence2. In this paper, the term number will henceforth mean any natural number. Phase I: Investigating {1, n,...} Sequences My research with Dr. Knapp this summer focused on finding ways to create a weakly complete sequence beginning with a given set of natural numbers in ascending order, using the last initial term as the threshold of completeness and having as few terms as possible. If we are given the initial terms of the sequence, we can obtain the next term by examining every number greater than the threshold of completeness in ascending order, and searching for the least number that cannot be formed by adding any distinct previous terms of the sequence. 1 2 Ross Honsberger, Mathematical Gems III (Mathematical Association of America, 1985), 123. Eric Schissel, “Characterizations of Three Types of Completeness,” Fibonacci Quarterly 27 (1989), 412-3. To illustrate how a weakly complete sequence is formed, consider the sequence with initial terms 1 and 5 (this was the first sequence which Dr. Knapp and I investigated). We know that 6 is not in the sequence because 6 = 1 + 5, but 7 cannot be formed by adding any distinct combination of 1 and 5, so 7 is the next term in the sequence, which is now S = {1, 5, 7}. 8 = 7 + 1, so 8 is not in the sequence, but 9 cannot be formed from any combination of 1, 5, or 7, so we add 9 to the sequence to get S = {1, 5, 7, 9}. 10 = 11 + 1, so 10 is not in the sequence, but 11 cannot be formed by adding any set of distinct elements in S, so 11 must be the next term in the sequence, and we have S = {1, 5, 7, 9, 11}. 12 = 11 + 1 = 7 + 5, so 12 is not in the sequence, and neither is 13 (because 13 = 7 + 5). Continuing on in this fashion, we now have the sequence S = {1, 5, 7, 9, 11, 29, 31, 89, 91, 269, 271, 809, 811,...} Note that this sequence consists of pairs of numbers that are two apart from each other. Starting with 9 and 11, if one examines the number between each number in one of these pairs (10, 30, 90, 270, 810, etc.), one notices that each of these numbers is three times the one before it. Therefore, each element of the sequence is equal to 10 * 3i ± 1 for any natural number i. The first phase of our research was to investigate other sequences beginning with 1 and another number n and determine if there were similar patterns in the terms of these sequences. The sequences beginning with 1 and n for each n from 3 to 10 are shown in Figure 1. The terms of sequence for beginning with 1 and 6 appear to be 8 followed by 11 * 3i ± 1 for i = 0, 1, 2,... The sequence beginning with 1 and 7 has 9 as its next term, but the next terms are sets of three numbers that are 2 apart from each other. Notice that the average of the terms in each set (i.e., the number around which set is centered) is 4 times the average of the terms of the previous set. Each of these sets is equal to 13 * 4i plus or minus 2 or 0. Using mathematical notation, we can write this sequence as 2 i 0 j 0 S {1,7,9} S i , where S i {13 4 i 2 2 j} . In each subsequent sequence that I investigated, I grouped the terms into sets of similar numbers, found the number about which each of these set was centered and the range of the terms in each set, and looked for patterns in these numbers. Through investigation, I found that the sequence beginning with 1 and 8 is 2 S {1,8,10} 14 4 i 2 2 j . i 0 j 0 The sequence beginning with 1 and 9 is 3 S {1,9,11} {16 5i 3 2 j} i 0 j 0 The sequence beginning with 1 and 10 is 3 S {1,10,12} {17 5i 3 2 j} i 0 j 0 Using as a guide a proof of the conjecture for the {1, 5,...} sequence which Dr. Knapp had already written beforehand3, I then wrote proofs of the conjectures for the {1, 6,...}, {1, 4,...}, {1, 7,...}, and {1, 9,...}sequences, given in figures in Figures 2 through 5. Our next goal was to find a formula for the general formula for a sequence beginning with {1, n,...} for any value of n. Finding the general formula consisted basically of looking at each formula for a specific value of n and determining a pattern in each aspect of the formula. I arrived at the conclusion that for the sequence beginning with {1, n,...} for any n ≥ 3, the sequence is b i 0 j 0 S {1, n, n 2} S i , where S i {si , j } , 3 M. Knapp, unpublished proof. n 1 and si,j = axi – b + 2j, where x , a = n + x + 2, and b = x – 2. 2 One we had found the formula, our next step was to prove it. In writing this proof, I used the previous proofs that I had written as a guide. The proof for the general case followed the same line of reasoning as the previous proofs, except that some statements of the general proof required more rigorous proof than their counterparts in the proofs for the more specific examples, which one could verify by simple calculation. The actual proof for the general case is given in Figure 6; the steps of the proof are outlined below: 1. Starting with 1 and n, prove that n + 2 and the elements of S0 are the next terms of the sequence. Then we know that we can represent every number from n to s0, b as a sum of distinct previous terms of the sequence. 2. Let Px S S i , and assume that the sequence begins with Pk for some i x 1 k ≥ 0. We then need to show that the next terms of the sequence are the elements of Sk+1. 3. First, we need to show that every number less than sk+1, 0 can be represented as a sum of distinct terms of the sequence. Define the set R as the set of all numbers represented as a sum of one or more elements of Pk 1 . Then by definition of the sequence, we know that R contains 1 and every number from n to axk – b – 1 inclusive. 4. Let Cm be the set whose elements are the all the possible sums of terms of Sk. We can represent every number of the same parity (even or odd) from the minimum value of Cm to the maximum value of Cm. By adding 1 to each element of Cm, we can represent every number from the minimum value of Cm plus 1 to the maximum value of Cm plus 1. By combining these two sets, we have representations for every number from the minimum of Cm to the maximum value of Cm plus 1, and we will call this interval Am. 5. We can also add each element cj of Cm to each of the remaining elements of R, so we now have a representation for every number from cj + n to cj + axk – b – 1. Once we show that the intervals of representation for consecutive values of j intersect or are consecutive, we know that we can represent every number from the smallest value of cj plus n to the largest value cj plus axk – b – 1. (Note: To prove continuous representation between two intervals of integers, we show that the difference when we subtract the smallest element of one interval from the greatest element of the other interval, the difference is non-negative (meaning the two intervals intersect) or -1 (meaning the two intervals are disjoint but consecutive). 6. Find the intervals of representation for A1 and B1, Ab and Bb, and Ab+1 and Bb+1 (note that there are b + 1 terms in each Si). We can find representations for any number between these intervals by adding one or more elements of Sk to either the sum of all of the elements of Pk 1 or the sum of all of the elements of Pk 1 except 1. 7. If n ≥ 9, then b ≥ 3, so there exists at least one integer between 1 and b – 1, so we need to show that there is continuous representation from Am to Bm for all values of m such that 2 ≤ m ≤ b – 1. 8. Prove that there is continuous representation from Am Bm to Am1 Bm1 for all values of m such that 0 ≤ m < b. Then we have proven that we can represent every integer from n to sk+1, 0. 9. We now need to show that the elements of Sk+1 cannot be represented as sums of previous terms of the sequence. Note that because 1 is in the sequence, once we show that an element of Sk+1 is in the sequence, we will know that that element plus 1 is not in the sequence. We first show that any representation of an element of Sk+1 cannot be represented using previous elements of Sk+1. 10. Since each element of Sk+1 is larger than the sum of all the elements of Pk 1 , we know that any representation of an element of Sk+1 must use at least one element of Sk. We then show that unless m = b + 1 (i.e., the number of terms in Sk), the difference between any element of Sk+1 and any element of Cm is too large to be represented using only the elements of Pk 1 . 11. We then show that if we subtract all of the elements of Sk+1, the difference is an element of Sk, which by definition of the sequence cannot be represented as a sum of elements of Pk 1 . Therefore, the elements of Sk+1 cannot be represented as sums of previous terms of S, so these elements must be the next terms of S, and thus we have shown by induction that the sequence follows the formula stated in the conjecture. QED. Phase II: Developing a Program The next phase of our research was to find formulas for weakly complete sequences that began with any set of initial terms, such as {1, 2, n,...}, {2, n,...}, {n, n + 1}, and {n, 2n}. However, calculating these sequences by hand would be quite tedious. Therefore, we needed a computer program that would generate sequences quickly and efficiently. To calculate the {1,n,...} sequences (see Figure 1), Dr. Knapp had used a program that he had created using the Maple software package, which he had to modify manually every time he wanted to test a different sequence. Using the programming skills that I had learned in my freshman computer science class, I created a Java version of Dr. Knapp’s program, and modified it so that it could calculate any {1, n,...} sequence. This was version 1 of the program, and the Java code for it is given in Figure 7. Version 2 of the program calculates the sequence beginning with any set of initial terms, and the code for its most up-to-date incarnation, version 2.2, is given in Figure 8. Unfortunately, version 2 had several serious flaws in the design. First, the user had to indicate at the beginning of the program’s execution how many initial terms he/she was entering. Secondly, the initial terms had to be entered in ascending order for the program to run properly. Finally, every time the user wanted to change even one initial term in the sequence, he would have to execute the program and re-enter every initial term all over again. I concluded that the best way to resolve these issues would be to create a version of the program that used a graphical user interface. The only problem was that I did not yet know how to create graphics using Java. I solved this problem by teaching myself using the Java All-in-One Desk Reference for Dummies by Doug Lowe and Barry Burd (Wiley, 2007), and within a few weeks was able to create version 3, the graphical version of the Sequence Program. The code for version 3.12 is given in Figure 9, and a screen shot of the program is shown in Figure 10. A description of the features of the program follows: • Initial Terms List: Shows the numbers that the user has defined to be at the beginning of the sequence. • Adding a Term: The user enters the term to be added to the list of initial terms in the Next Term box and clicks the Add Term button. The program is set up so that the user need not enter the initial terms in ascending order. • Changing an Initial Term: The user selects the term in the Initial Terms list that he wants to change, enters the new value of the selected term into the Current Term box, and clicks the Update Term button. The program automatically places the new term in its appropriate place in the list. • Removing Terms from the List: The user selects the term that he wants to remove from the list of initial terms and clicks the Remove Term button to remove the term from the list. Additionally, the user can remove all of the terms from the list by clicking the Clear All Initial Terms button. • Calculation Range: The program only displays the terms of the sequence that are less than the number in this box. • Display Numbers with Multiple Representations: The user can toggle this option on or off. This indicates if any number in the range of calculation can be written as a sum of distinct previous terms of the sequence in more than one way. The user can set minimum number of representations that a number must have to be displayed. • Calculate Sequence: Calculates the sequence beginning with the numbers in the Initial Terms list, and displays them in the text frame below. Each sequence that the user generates is added to the text box after the previously calculated sequences. There are also buttons available to clear the output display and to print the outputs directly from the program. Phase III: Investigating Other Weakly Complete Sequences Now that I had a program to efficiently generate series of sequences, I could now investigate different types of sequences. The first set of sequences that I looked at were the sequences beginning with {1, 2, n,...}. These sequences are given in Figure 11. Using the same investigation techniques that I had used earlier, I found that for n ≥ 5, the sequence is S = {1, 2, n, n + 4} {S i } , i 0 x2 where Si = {s j 0 i, j n 3 } , and si,j = axi – 2 (x – 2) + 4j, where x = , and a = n + 2x + 4. 4 Though I have not yet written a proof of this conjecture, the techniques for proving it should be similar to those used to prove the {1, n,...} formula. Next, I generated sequences beginning with {2, n,...}, and these are shown in Figure 12. Notice that while each of these sequences still has groups of similar numbers, there is an unusual pattern in each of these subsets – some numbers are 1 apart from each other, some are 3 apart, and if n is congruent to 3 modulo 4, there are some numbers that are 4 apart from each other. If we calculate the averages of the terms in each subset of a sequence, we find that these averages form a geometric sequence; i.e., there is a constant ratio of the average of one subset to the average of the previous subset. The sequences seem to have the following pattern: n2 i 0 j 0 y 0 S {2, n, n 1} S i , where S i {si , j } {si , 4 y 2 , si , 4 y 3 } , and si,,j = axi – b + j However, I was unable to determine formulae for a, x, or b. I then decided to investigate the {n, n + 1,...} sequences. These are shown in Figure 13. Once again, I compared the averages of each subset of a sequence and found that they formed a geometric sequence in which the ratio was equal to n. Using quadratic curve-fitting with the aid of the MATLAB software package, I was able to determine a value for a in terms of n. The n2 i 0 j 0 formula that I found was: S = {n, n + 1} {S i } , where S i {si , j } , and si , j an i b j , where a 3n 2 n2 and b . The proof is given in Figure 16. 2 2 Using similar techniques, I found the formulae for the following sequences: n 1 i 1 j 0 Start with n, n + 2: S = {n, n 2, n 3, n 4,...2n 1} S i , where S i {si , j } {si ,1 } , and si , j an i n n2 3n n 6 . This works for n ≥ 2. j , where a 2(n 1) 2(n 1) 2 2 n 1 i 1 j 0 Start with n, n + 3: S = {n, n 3, n 4,...2n 2} S i , where S i {si , j } {si , 2 } , and si , j an i n2 n 4 3n 2 3n 10 . This works for n ≥ 4. j , where a 2(n 1) 2(n 1) n 1 i 1 j 0 Start with n, n + 4: S = {n, n 4, n 5...2n 3} S i , where S i {si , j } {si ,3 } , and si , j an i n n6 3n 5n 14 . This works for n ≥ 5. j , where a 2(n 1) 2(n 1) 2 2 n 1 i 1 j 0 Start with n, n + 4: S = {n, n 5, n 6...2n 4} S i , where S i {si , j } {si , 4 } , and si , j an i n2 n 8 3n 2 7n 18 . This works for n ≥ 6. j , where a 2(n 1) 2(n 1) The sequences themselves are shown in Figures 15 through 18. Notice that these formulae seem to hold only when n > m. When n < m or n = m, these formulae are no longer valid, and the patterns when n < m and when n = m are different as well. With this in mind, I decided to categorize all sequences that begin with n and n + m in terms of the value of n compared to m. The three categories are alpha sequences (denoted by (n, m) ), in which n > m; beta sequences (denoted by (n) ), in which n = m; and gamma sequences (denoted by ( n, m) ), in which n < m. After analyzing the patterns in formulae that I had obtained for specific alpha sequences, I determined that the general formula for an alpha sequence is: (n, m) {n, n m, n m 1, n m 2,...,2n m 1} S i , i 1 n 1 where S i si , j si ,m1 , and si , j an i b j , j 0 where a 3n 2 (2m 3)n 4m 2 n 2 n 2(m 1) , and b 2(n 1) 2(n 1) I also investigated the set of beta sequences (i.e., the sequences that start with {n, 2n}), which are shown in Figure 19, and determined that the formula for a beta sequence is: (n) {n,2n,2n 1,2n 2,...,3n 1,4n} S i , i 1 n2 where S i si , j , and si , j an i b j , where a j 0 n2 5n 2 n 6 , and b 2 2(n 1) The final week of my research this summer was spent in writing the proof for this formula, which is given in Figure 20. Conclusions and Future Research Throughout my investigation of weakly complete sequences, I found that the formula for a particular sequence tends to follow a specific paradigm. A sequence beginning with {n, n + m} starts with the initial terms, followed by an infinite series of subsets containing similar numbers. Between the initial terms and the infinite series, there may exist other terms that do not belong to a particular subset, and the values of these terms depend on n and m. Each subset Si of the sequence is an indexed set of terms si, j. The range of Si and the terms that are omitted from it are dependent upon the values of n and m. The formula si, j = axi – b + j seems to be consistent for all sequences, but the values of a, x, and b are all determined by the values of n and m. We have found and proven a formula for sequences beginning with {1, n,...}, and our categorization of sequences with two given initial terms into alpha, beta, and gamma sequences should set the tone for future research on weakly complete sequences. We have found and proven a formula for all beta sequences, and we have a conjecture for the general formula for all alpha sequences that needs only to be proven. However, though we did investigate some gamma sequences and conjectured on parts of the formulae for some, the patterns in the formulae for gamma sequences have so far eluded us. The subsets of these sequences increase in size as both n and m increase, which makes many calculations involving these sequences rather tedious. However, anyone with access to powerful computing machinery might be able to process these sequences more efficiently and perhaps determine what the pattern is, if there even is one. Finally, our research for this summer focused only on sequences that had two given initial terms. Weakly complete sequences with three or more initial terms may also be of interest to future researchers. The ultimate goal of future research on this topic is to find a single unifying formula that can determine the pattern for any weakly complete sequence. Figure 1. Sequences for 1, n for n from 1 to 10. Start with 1, 3 Get 1, 3, 5, 7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, ... Start with 1, 4 Get 1, 4, 6, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, ... Start with 1, 5 Get 1, 5, 7, 9, 11, 29, 31, 89, 91, 269, 271, 809, 811, 2429, 2431, 7289, 7291, ... Start with 1, 6 Get 1, 6, 8, 10, 12, 32, 34, 98, 100, 296, 298, 890, 892, 2672, 2674, 8018, 8020, ... Start with 1, 7 Get 1, 7, 9, 11, 13, 15, 50, 52, 54, 206, 208, 210, 830, 832, 834, 3326, 3328, 3330, ... Start with 1, 8 Get 1, 8, 10, 12, 14, 16, 54, 56, 58, 222, 224, 226, 894, 896, 898, 3582, 3584, 3586, ... Start with 1, 9 Get 1, 9, 11, 13, 15, 17, 19, 77, 79, 81, 83, 397, 399, 401, 403, 1997, 1999, 2001, 2003, 9997, 9999, ... Start with 1, 10 Get 1, 10, 12, 14, 16, 18, 20, 82, 84, 86, 88, 422, 424, 426, 428, 2122, 2124, 2126, 2128, ... Figure 2. Proof for the {1, 6,...} Sequence Theorem: Consider the sequence 1, 6, 8,..., which is defined by setting the first two terms equal to 1 and 6, and then demanding that every integer n ≥ 7 must be a sum of distinct terms of the sequence. Then this sequence is given by: 1, 6, 8, 10, 12, 32, 34, 98, 100, 296, 298... i.e., 1, 6, 8, 11 ∙ 30 ± 1, 11 ∙ 31 ± 1, 11 ∙ 32 ± 1, 11 ∙ 33 ± 1, .... Proof: By definition, 1 and 6 are the first two terms of the sequence, and we can find that the next three terms are 8, 10, and 12. Note that 10 = 11 ∙ 30 – 1, and 12 = 11 ∙ 30 + 1; this is our base case for proof by induction. Now assume that the sequence begins with the terms 1, 6, 8, 11 ∙ 30 ± 1,..., 11 ∙ 3k ± 1, where k ≥ 0. We now need to show that the next two terms of the sequence are 11 ∙ 3k+1 + 1 and 3k+1 – 1. First, we need to show that every integer less than 11 ∙ 3k+1 – 1 can be represented as a sum of distinct terms in the sequence. By definition of the sequence, we know that every integer up to 11 ∙ 3k + 1 can be represented, so now we only need to prove that any integer n with 11 ∙ 3k + 2 ≤ n ≤ 11 ∙ 3k+1 – 2 can be represented. Let B be the set whose elements are the terms of the sequence that are strictly less than 11 ∙ 3k – 1. Then by definition of the sequence, the elements of B represent 1 and every integer between 6 and 11 ∙ 3k – 2 inclusive. By adding 11 ∙ 3k – 1 to each of these numbers, we find that our sequence represents the number 11 ∙ 3k and all numbers between 11 ∙ 3k + 5 and (11 ∙ 3k – 2) + (11 ∙ 3k – 1) = 2 ∙ 11 ∙ 3k – 3. Similarly, by adding 11 ∙ 3k + 1 to each number represented by B, we find that we can represent 11 ∙ 3k + 2 and all the numbers from 11 ∙ 3k + 7 to (11 ∙ 3k – 2) + (11 ∙ 3k + 1) = 2 ∙ 11 ∙ 3k – 1. Now if we note that (11 ∙ 3k – 1) + (11 ∙ 3k + 1) = 2 ∙ 11 ∙ 3k, we find that by adding both of these terms to each number represented by B, we can represent the number 2 ∙ 11 ∙ 3k + 1 and all of the numbers from 2 ∙ 11 ∙ 3k + 6 to (11 ∙ 3k – 2) + (2 ∙ 11 ∙ 3k) = 3 ∙ 11 ∙ 3k – 2 = 11 ∙ 3k+1 – 2. Putting all of this information together, we have representations for all numbers up to 11 ∙ 3k+1 – 2, with the possible exceptions of 11 ∙ 3k + 3 11 ∙ 3k + 4 2 ∙ 11 ∙ 3k + 2 2 ∙ 11 ∙ 3k + 4 2 ∙ 11 ∙ 3k + 5. 2 ∙ 11 ∙ 3k + 3 Note that b = 1 + 6 + 8 + (11 ∙ 30 – 1) + (11 ∙ 30 + 1) +...+ (11 ∙ 3k–1 – 1) + (11 ∙ 3k–1 + 1) bB = 15 + 2 ∙ 11 ∙ k 1 3 i i 0 3k 1 2 = 11 + 4 + 11 ∙ (3k – 1) = 4 + 11 ∙ (1 + 3k – 1) = 11 ∙ 3k + 4. = 15 + 2 ∙ 11 ∙ Now note that we have the following sums: 11 ∙ 3k + 3 = b bB {1} 11 ∙ 3k + 4 = b bB 2 ∙ 11 ∙ 3 + 2 = (11 ∙ 3k – 1) + k b bB {1} b 2 ∙ 11 ∙ 3k + 4 = (11 ∙ 3k + 1) + b 2 ∙ 11 ∙ 3k + 3 = (11 ∙ 3k – 1) + bB bB {1} 2 ∙ 11 ∙ 3 + 5 = (11 ∙ 3 + 1) + b . k k bB This shows that our sequence represents every number less than 11 ∙ 3k + 1 – 1. Next, we need to show that 11 ∙ 3k + 1 – 1 is not represented by the terms of the sequence up to 11 ∙ 3k + 1. First, note that since 11 ∙ 3k + 1 – 1 > 11 ∙ 3k + 4 = b , bB any such representation must use one or both of the numbers 11 ∙ 3k – 1 and 11 ∙ 3k + 1. If we try to use only 11 ∙ 3k – 1, we find that the elements of B must represent (11 ∙ 3k+1 – 1) – (11 ∙ 3k – 1) = 2 ∙ 11 ∙ 3k, and this number is too large to be represented by only the elements of B. Similarly, if we try to use only 11 ∙ 3k + 1, then the elements of B must represent (11 ∙ 3k+1 – 1) – (11 ∙ 3k + 1) = 2 ∙ 11 ∙ 3k – 2, and this is also too large to be represented with only the elements of B. If we try using both of these elements, then the elements of B must represent (11 ∙ 3k+1 – 1) – (11 ∙ 3k + 1) – (11 ∙ 3k - 1) = 11 ∙ 3k – 1. But since 11 ∙ 3k – 1 is an element of the sequence, it cannot be represented as a sum of elements of B. Therefore, 11 ∙ 3k+1 – 1 cannot be represented as a sum of previous terms in the sequence, and must therefore be the next term. Since 11 ∙ 3k+1 = (11 ∙ 3k+1 – 1) + 1, it is obvious that 11 ∙ 3k+1 is not in the sequence. All that remains is to show that 11 ∙ 3k+1 + 1 cannot be represented as a sum of any of the previous terms of the sequence. Since 11 ∙ 3k+1 + 1 = (11 ∙ 3k+1 – 1) + 2, and the number 2 is not in the sequence, we know that we cannot use 11 ∙ 3k+1 – 1 in our representation. Following the same reasoning that we used for 11 ∙ 3k+1 – 1, we find that any representation of 11 ∙ 3k+1 + 1 must use both 11 ∙ 3k – 1 and 11 ∙ 3k + 1, and therefore the difference (11 ∙ 3k+1 + 1) – [(11 ∙ 3k + 1) + (11 ∙ 3k - 1)] = 11 ∙ 3k + 1 would have to be represented using only the elements of B. Again, because 11 ∙ 3k + 1 is in the sequence, we know by definition that it cannot be a sum of any distinct elements of B. Therefore, 11 ∙ 3k + 1 is the next term in the sequence, and thus by induction we have established the pattern for the sequence as stated in the theorem. QED. Figure 3. Proof for {1, 4} Sequence Theorem: Consider the sequence 1, 4, 6,..., which is defined by setting the first two terms equal to 1 and 4, and then demanding that every integer n ≥ 5 be a sum of distinct terms of the sequence. Then the sequence is given by: 1, 4, 6, 8, 16, 32, 64, ..., i.e., 1, 4, 6, 8 ∙ 20, 8 ∙ 21, 8 ∙ 22, 8 ∙ 23, .... Proof: By definition, 1 and 4 are the first two terms of the sequence. Then it is easy to find that the next two terms are 6 and 8. Note that 8 = 8 ∙ 20; this is our base case for proof by induction. Now assume that the sequence begins with the terms: 1, 4, 6, 8 ∙ 20, ..., 8 ∙ 2k, where k ≥ 0. We need to show that the next term of the sequence is 8 ∙ 2k+1. First, we need to show that every number less than 8 ∙ 2k+1 – 1 can be represented as a sum of previous terms in the sequence. By definition of the sequence, we know that every integer up to 8 ∙ 2k can be represented, so now we just need to prove that any integer n such that 8 ∙ 2k + 1 ≤ n ≤ 8 ∙ 2k+1 – 1 can be represented. Let B be the set whose elements are the terms of the sequence strictly less than 8 ∙ 2k. Then by definition of the sequence, the elements of B represent the number 1 and every integer from 4 to 8 ∙ 2k – 1 inclusive. By adding 8 ∙ 2k to each of these numbers, we find that our sequence represents the number 8 ∙ 2k + 1 and all of the numbers from 8 ∙ 2k + 4 to (8 ∙ 2k – 1) + 8 ∙ 2k = 8 ∙ 2k+1 – 1. Now we have representations for all numbers less than 8 ∙ 2k+1 except 8 ∙ 2k + 2 and 8 ∙ 2k + 3. Note that b = 1 + 4 + 6 + 8 ∙ 2 0 + 8 ∙ 21 + 8 ∙ 22 + ... + 8 ∙ 2k – 1 bB k 1 = 11 + 8 2 i i 0 = 3 + 8 + 8 (2k – 1) = 3 + 8 (1 + 2k – 1) = 8 ∙ 2k + 3. Then we have 8 ∙ 2k + 3 = b and 8 ∙ 2 bB k +2= b . This shows that our sequence represents every bB {1} number less than 8 ∙ 2k+1. Now we need to show that 8 ∙ 2k+1 cannot be represented by the terms of to the sequence up to 8 ∙ b , any representation of 8 ∙ 2k+1 must use the term 8 ∙ 2k. Then the 2k. First, note that since 8 ∙ 2k+1 > bB difference 8 ∙ 2k+1 – 8 ∙ 2k = 8 ∙ 2k must be represented by the elements of B. But this is impossible, because 8 ∙ 2k is an element of the sequence, and thus by definition cannot be represented by the elements of B. Therefore, 8 ∙ 2k+1 cannot be represented as a sum of previous terms in the sequence, and hence must be the next term of the sequence. Thus by induction, we have established the pattern for the sequence as stated in the theorem. QED. Figure 4: Proof for {1, 7} Sequence Theorem: Consider the sequence 1, 7, 9, ..., which is defined by setting the first two terms equal to 1 and 7, and then demanding that every integer n ≥ 8 be a sum of distinct terms of the sequence. Then this sequence is given by: 1, 7, 9, 11, 13, 15, 50, 52, 54, 206, 208, 210, ..., i.e., 1, 7, 9, 13 ∙ 40 + c, 13 ∙ 41 + c, 13 ∙ 42 + c, ..., where c {-2, 0, 2}. Proof: By definition, the first two terms of the sequence are 1 and 7, and we can then figure out that the next four terms are 9, 11, 13, and 15. Note that 11 = 13 ∙ 40 – 2, 13 = 13 ∙ 40, and 15 = 13 ∙ 40 + 2. Now assume that the sequence begins with the terms 1, 7, 9, 13 ∙ 40 + c, ..., 13 ∙ 4k + c, where k ≥ 0. We need to show that the next three terms of the sequence are 13 ∙ 4k+1 – 2, 13 ∙ 4k+1, and 13 ∙ 4k+1 + 2. First, we need to show that every integer less than 13 ∙ 4k+1 – 2 can be represented as a sum of distinct terms in the sequence. By definition of the sequence, we know that every integer up to 13 ∙ 4k + 2 can be represented, so we just need to prove that every integer n for 13 ∙ 4k + 3 ≤ n ≤ 13 ∙ 4k+1 – 3 inclusive has a representation. Let B be the set whose elements are the terms of the sequence strictly less than 13 ∙ 4k – 2. Then by definition of the sequence, the elements of B represent 1 and every integer between 7 and 13 ∙ 4k – 3 inclusive, and we will define the set P (B) to be the set whose elements are these numbers. By adding 13 ∙ 4k – 2 to each of these numbers, we can represent the number 13 ∙ 4k – 1 and every number from 13 ∙ 4k + 5 to (13 ∙ 4k – 3) + (13 ∙ 4k – 2) = 2 ∙ 13 ∙ 4k – 5. Similarly, by adding 13 ∙ 4k to each element of P (B), we can represent 13 ∙ 4k + 1 and every integer from 13 ∙ 4k + 7 to (13 ∙ 4k – 3) + 13 ∙ 4k = 2 ∙ 13 ∙ 4k – 3. We can also add 13 ∙ 4k + 2 to each element of P(B) and find that we can represent 13 ∙ 4k + 3 and every number from 13 ∙ 4k + 9 to (13 ∙ 4k – 3) + (13 ∙ 4k + 2) = 2 ∙ 13 ∙ 4k – 1. Now if we note that (13 ∙ 4k – 2) + 13 ∙ 4k = 2 ∙ 13 ∙ 4k – 2, we see that by adding both of these terms to the elements of P(B), we can represent 2 ∙ 13 ∙ 4k – 1 and all numbers from 2 ∙ 13 ∙ 4k + 5 to (13 ∙ 4k – 3) + (2 ∙ 13 ∙ 4k – 2) = 3 ∙ 13 ∙ 4k – 5. Similarly, we can add (13 ∙ 4k – 2) + (13 ∙ 4k + 2) = 2 ∙ 13 ∙ 4k to each element of P(B) and thus represent 2 ∙ 13 ∙ 4k + 1 and every number from 2 ∙ 13 ∙ 4k + 7 to (13 ∙ 4k – 3) + (2 ∙ 13 ∙ 4k) = 3 ∙ 13 ∙ 4k – 3, and we can add (13 ∙ 4k) + (13 ∙ 4k + 2) = 2 ∙ 13 ∙ 4k + 2 to each element of P(B) and represent 2 ∙ 13 ∙ 4k + 3 and every number from 2 ∙ 13 ∙ 4k + 9 to (13 ∙ 4k – 3) + (2 ∙ 13 ∙ 4k + 2) = 3 ∙ 13 ∙ 4k – 1. Finally, if we note that (13 ∙ 4k – 2) + (13 ∙ 4k) + (13 ∙ 4k + 2) = 3 ∙ 13 ∙ 4k, we can add all three terms to the elements of P(B) and represent 3 ∙ 13 ∙ 4k + 1 and every number from 3 ∙ 13 ∙ 4k + 7 to (13 ∙ 4k – 3) + (3 ∙ 13 ∙ 4k) = 4 ∙ 13 ∙ 4k – 3 = 13 ∙ 4k+1 – 3. Putting all of this information together, we find that we can represent all numbers up to 13 ∙ 4k+1 – 3, with the possible exceptions of 13 ∙ 4k + 4, 2 ∙ 13 ∙ 4k + 6 4, and (3 13 4 k i). i 2 Note that b = 1 + 7 + 9 + (13 ∙ 40 – 2) + 13 ∙ 40 + (13 ∙ 40) +...+ (13 ∙ 4k–1 – 2) + 13 ∙ 4k–1 + (13 ∙ 4k–1 + 2) bB = 17 + 3 ∙ 13 k 1 4 i i 0 4k 1 3 k = 4 + 13 + 13 (4 – 1) = 4 + 13 (1 + 4k – 1) = 13 ∙ 4k + 4. = 17 + 3 ∙ 13 ∙ Now note that we have the following sums: 13 ∙ 4k + 4 = b bB 2 ∙ 13 ∙ 4 + 4 = (13 ∙ 4k) + k b bB 3 ∙ 13 ∙ 4 + 2 = (13 ∙ 4 – 2) + (13 ∙ 4k) + k k b bB b 3 ∙ 13 ∙ 4 + 3 = (13 ∙ 4 – 2) + (13 ∙ 4 + 2) + k k k bB {1} b b 3 ∙ 13 ∙ 4k + 4 = (13 ∙ 4k – 2) + (13 ∙ 4k + 2) + bB 3 ∙ 13 ∙ 4 + 5 = (13 ∙ 4 ) + (13 ∙ 4 + 2) + k k k bB {1} 3 ∙ 13 ∙ 4 + 6 = (13 ∙ 4 ) + (13 ∙ 4 + 2) + b . k k k bB This shows that our sequence represents every number less than 13 ∙ 4k+1 – 2. Next, we need to show that 13 ∙ 4k+1 – 2 is not represented by the terms of the sequence up to 13 ∙ 4k + 2. First, note that since 13 ∙ 4k+1 – 2 > 13 ∙ 4k + 4 = b , bB any such representation must one or more of the numbers 13 ∙ 4k – 2, 13 ∙ 4k, or 13 ∙ 4k + 2. If we try to use only 13 ∙ 4k + 2, the largest of these, we find that the elements of B must represent (13 ∙ 4k+1 – 2) – (13 ∙ 4k + 2) = 3 ∙ 13 ∙ 4k – 4, and this number is too large to be represented by only the elements of B, and if we try to use either of the smaller elements by itself, the difference will also be too large. The largest sum that we can make with a pair of the above elements is (13 ∙ 4k) + (13 ∙ 4k + 2) = 2 ∙ 13 ∙ 4k + 2, so if we use both of these elements in our representation, the difference (13 ∙ 4k+1 – 2) – (2 ∙ 13 ∙ 4k + 2) = 2 ∙ 13 ∙ 4k – 4 is once again too large to be represented using only the elements of B. Our last option is to try using all three of the above elements, and we find that the elements of B must represent (13 ∙ 4k+1 – 2) – [(13 ∙ 4k – 2) + (13 ∙ 4k) + (13 ∙ 4k + 2)] = 13 ∙ 4k – 2. But since 13 ∙ 4k – 2 is an element of the sequence, we know by definition that it cannot be represented as sum of the elements of B. Therefore, 13 ∙ 4k+1 – 2 cannot be represented as a sum of previous terms in the sequence, and must therefore be the next term. Since 13 ∙ 4k+1 – 1 = (13 ∙ 4k+1 – 2) + 1, it is obvious that 13 ∙ 4k+1 is not in the sequence. Our next step is to show that 13 ∙ 4k+1 cannot be represented as a sum of any of the previous terms in the sequence. Since 13 ∙ 4k+1 = (13 ∙ 4k+1 – 2) + 2, and the number 2 is not in the sequence, we cannot use 13 ∙ 4k+1 – 2 in our representation. Following the same reasoning that we used for 13 ∙ 4k+1 – 2, we find that any representation of 13 ∙ 4k+1 must use 13 ∙ 4k – 2, 13 ∙ 4k, and 13 ∙ 4k + 2, and therefore the difference (13 ∙ 4k+1) – [(13 ∙ 4k – 2) + (13 ∙ 4k) + (13 ∙ 4k + 2)] = 13 ∙ 4k would have to be represented using only the elements of B. But this is impossible, since 13 ∙ 4k is in the sequence, and thus by definition cannot be represented by the elements of B. Hence, we cannot represent 13 ∙ 4k+1 as a sum of previous terms of the sequence, so this must be the next term in the sequence. Since 13 ∙ 4k+1 + 1 = (13 ∙ 4k+1) + 1, we know that 13 ∙ 4k+1 + 1 is not in the sequence. Our final step here is to prove that 13 ∙ 4k+1 + 2 cannot be represented as a sum of previous terms of the sequence. Since 13 ∙ 4k+1 + 2 = (13 ∙ 4k+1 – 2) + 4 = (13 ∙ 4k+1) + 2, and the numbers 2 and 4 are not in the sequence, we cannot use 13 ∙ 4k – 2 or 13 ∙ 4k+1 in our representation of 13 ∙ 4k+1 + 2. Using the same reasoning as before, we know our representation must use 13 ∙ 4k – 2, 13 ∙ 4k, and 13 ∙ 4k + 2. The difference (13 ∙ 4k+1 + 2) – [(13 ∙ 4k – 2) + (13 ∙ 4k) + (13 ∙ 4k + 2)] = 13 ∙ 4k + 2 is already in the sequence, so it cannot be represented as a sum of the elements of B. Therefore, 13 ∙ 4k+1 + 2 cannot be represented as a sum of previous terms, and must therefore be the next term in the sequence. Thus we have shown by induction that the sequence follows the pattern given in the theorem. QED. Figure 5. Proof for {1, 9} Sequence Theorem: Define the sequence S = {1, 9, 11, ...} by setting the first two terms equal to 1 and 9, and then demanding that every integer x ≥ 10 be a sum of distinct terms of S. Then this sequence is given by: S = {1, 9, 11, 13, 15, 17, 19, 77, 79, 81, 83, 397, 399, 401, 403, 1997, 1999, 2001, 2003, ...} = {1, 9, 11} {S i } , i 0 3 where Si = {s } , sj = 16 5 3 2 j . i j j 0 Proof: By definition, 1 and 9 are the first two terms of the sequence, and we can then figure out that the next five terms of the sequence are 11, 13, 15, 17, and 19. Note that {13, 15, 17, 19} = S0. Define the set Px S S i , i x 1 and assume that the sequence begins with Pk. We need to show the next terms of the sequence are the elements of Sk+1. First, we need to show that every integer less than 16 ∙ 5k+1 – 3 can be represented as a sum of distinct terms in the sequence. By definition, we know that every integer up to 16 ∙ 5k + 3 can be represented, so we just need to prove that every integer x for 16 ∙ 5k + 4 ≤ x ≤ 16 ∙ 5k+1 – 4 inclusive has a representation. Define the set R (f) as the set of all integers that can be represented as a sum of distinct elements of the set f. Then by definition of the sequence, we have R( Pk 1 ) {1} {x : x [9, 16 ∙ 5k – 4]}. We will now attempt to represent other numbers by adding one or more elements of Sk to each of the elements of R (Pk–1). We’ll start by adding one element of Sk to each element of R (Pk–1). Since 3 S k {16 5 k 3 2 j} , j 0 by adding 1 to each element of Sk, we can represent 3 {s j 0 3 j 1} {16 5 k 2 2 j} = {16 ∙ 5k – 2, 16 ∙ 5k, 16 ∙ 5k + 2, 16 ∙ 5k + 4}. j 0 The smallest element of Sk is 16 ∙ 5k – 3, and when we add this term to each of the remaining elements of R (Pk–1), we find that we can represent every number from (16 ∙ 5k – 3) + 9 = 16 ∙ 5k + 6 to (16 ∙ 5k – 3) + (16 ∙ 5k – 4) = 2 ∙ 16 ∙ 5k – 7. Similarly, by adding 16 ∙ 5k + 3, the largest element of Sk, to each of the elements, we find that we can represent every number from 16 ∙ 5k + 12 to (16 ∙ 5k + 3) + (16 ∙ 5k – 4) = 2 ∙ 16 ∙ 5k – 1. Next we will add pairs of elements of Sk to each element of R (Pk–1). We know by definition of the sequence that the sum of any two elements of Sk is equal to (16 ∙ 5k – 3 + 2 j1) + (16 ∙ 5k – 3 + 2 j2) = 2 ∙ 16 ∙ 5k – 6 + 2 (j1 + j2), where j1, j2 J = {0, 1, 2, 3} and j1 j2 . If we let j1 = 0, we can represent the sum j1 + j2 as 1, 2, or 3 if we let j2 equal any of the remaining numbers in J. Similarly, if we let j1 = 3 and let j2 equal any of the remaining numbers in J, we can represent 3, 4, or 5 as the sum j1 + j2. Thus we have shown that j1 + j2 can equal any integer from 1 to 5 inclusive, and by substitution, we find that the sum of any two elements of Sk is equal to 2 ∙ 16 ∙ 5k plus any even integer from -4 to 4 inclusive. For the sake of simplicity, we will call the set of all of these possible sums C2. Then by adding 1 to each element of C2, we can represent 2 ∙ 16 ∙ 5k plus any odd integer from -3 to 5 inclusive. By adding 2 ∙ 16 ∙ 5k – 4, the smallest element of C2, to each of the remaining elements of R (Pk–1), we can represent every number from (2 ∙ 16 ∙ 5k – 4) + 9 = 2 ∙ 16 ∙ 5k + 5 to (2 ∙ 16 ∙ 5k – 4) + (16 ∙ 5k – 4) = 3 ∙ 16 ∙ 5k – 8. Similarly, by adding 2 ∙ 16 ∙ 5k + 4, the largest element of C2, to each remaining element of R (Pk–1), we can represent every number from 2 ∙ 16 ∙ 5k + 13 to (2 ∙ 16 ∙ 5k + 4) + (16 ∙ 5k – 4) = (3 ∙ 16 ∙ 5k. Next, we will add sets of three elements of Sk to each element of R (Pk–1). By definition, we know that the sum of any three terms of Sk is equal to (16 ∙ 5k – 3 + 2 j1) + (16 ∙ 5k – 3 + 2 j2) + (16 ∙ 5k – 3 + 2 j3) = 3 ∙ 16 – 9 + 2 (j1 + j2 + j3), for distinct j1, j2, j3 {0, 1, 2, 3}. If we let j1 = 0, j2 = 1, and j3 = 2 or 3, we find that j1 + j2 + j3 = 3 or 4. If we let j1 = 3, j2 = 2, and j3 = 0 or 1, we find that j1 + j2 + j3 = 5 or 6. So j1 + j2 + j3 is equal to 3, 4, 5, or 6. Then by substitution, we find that the sum of any three terms of Sk is equal to 3 ∙ 16 ∙ 5k plus any odd integer from -3 to 3 inclusive, and we will call the set of all these possible sums C3. If we add 1 to each element of C3, we can represent 3 ∙ 16 ∙ 5k plus every even integer from -2 to 4 inclusive. By adding 3 ∙ 16 ∙ 5k – 3, the smallest element of C3, to each remaining element of R (Pk–1), we have a representation for every number from (3 ∙ 16 ∙ 5k – 3) + 9 = 3 ∙ 16 ∙ 5k + 6 to (3 ∙ 16 ∙ 5k – 3) + (16 ∙ 5k – 4) = 4 ∙ 16 ∙ 5k – 7. Similarly, by adding 3 ∙ 16 ∙ 5k + 3, the largest element of C3, to each of the remaining elements of R (Pk–1), we have a representation for 3 ∙ 16 ∙ 5k + 12 to (3 ∙ 16 ∙ 5k + 3) + (16 ∙ 5k – 4) = 4 ∙ 16 ∙ 5k – 1. Finally, if we add all four terms (the sum of which is 4 ∙ 16 ∙ 5k) to each element of R (Pk– k k k k 1), we can represent 4 ∙ 16 ∙ 5 + 1 and all numbers from 4 ∙ 16 ∙ 5 + 9 to (4 ∙ 16 ∙ 5 ) + (16 ∙ 5 – k k+1 4) = 5 ∙ 16 ∙ 5 – 4 = 16 ∙ 5 – 4. Putting all of the above information together, we have representations for every number less than 16 ∙ 5k+1 – 3 except 16 ∙ 5k + 5, 3 ∙ 16 ∙ 5k + 5, and 8 4 16 5 k i. i 2 Note that p = 1 + 9 + 11 + 4 ∙ 16 ∙ 50 + 4 ∙ 16 ∙ 51 + ... + 4 ∙ 16 ∙ 5k–1 pPk 1 k 1 = 21 + 4 ∙ 16 5 i i 0 5k 1 = 5 + 16 + 4 ∙ 16 ∙ 4 = 5 + 16 + 16 (5k – 1) = 5 + 16 (1 + 5k – 1) = 16 ∙ 5k + 5. Now note that we have the following sums: 16 ∙ 5k + 5 = p pPk 1 3 ∙ 16 ∙ 5 + 5 = 2 ∙ 16 ∙ 5k + k p pPk 1 4 ∙ 16 ∙ 5k + 2 = 3 ∙ 16 ∙ 5k – 3 + p pPk 1 4 ∙ 16 ∙ 5k + 3 = 3 ∙ 16 ∙ 5k – 1 + p pPk 1 {1} 4 ∙ 16 ∙ 5k + 4 = 3 ∙ 16 ∙ 5k – 1 + p pPk 1 4 ∙ 16 ∙ 5k + 5 = 3 ∙ 16 ∙ 5k + 1 + p pPk 1 {1} 4 ∙ 16 ∙ 5k + 6 = 3 ∙ 16 ∙ 5k + 1 + p pPk 1 4 ∙ 16 ∙ 5k + 7 = 3 ∙ 16 ∙ 5k + 3 + p pPk 1 {1} 4 ∙ 16 ∙ 5k + 8 = 3 ∙ 16 ∙ 5k + 3 + p. pPk 1 This shows that our sequence represents every number less than 16 ∙ 5k+1 – 4. Our next step is to show that each element of Sk+1 cannot be represented by the terms of the sequence up to 16 ∙ 5k + 4. For each element sj Sk+1 that we can prove is in the sequence, we can determine immediately that sj + 1 is not in the sequence. Note that since 16 ∙ 5k+1 – 3, the smallest element of Sk+1, is greater than p , any representation of an element of Sk+1 must use pPk 1 at least one element of Sk. If we use the smallest element of Sk+1, 16 ∙ 5k+1 – 3, and the greatest element of C3, 3 ∙ 16 ∙ 5k + 3, we find that the difference (16 ∙ 5k+1 – 3) – (3 ∙ 16 ∙ 5k + 3) = 2 ∙ 16 ∙ 5k – 6 is too large to represent using only the elements of Pk–1, so if we try using a greater element of Sk+1 and / or a smaller combination of elements of Sk, the difference will still be too large to be represented using only the elements of Pk–1. Therefore, our only option for any element of Sk+1 is to use all four elements of Sk in our representation. Then, for the jth element of Sk+1, our difference is (16 ∙ 5k+1 – 3 + 2 j) – (4 ∙ 16 ∙ 5k) = 16 ∙ 5k – 3 + 2 j would have to be represented by the elements of Pk–1. But this is impossible, because (16 ∙ 5k – 3 + 2 j) Sk, and by definition cannot be represented as a sum of the elements of Pk–1. So we know right away that 16 ∙ 5k+1 – 3 cannot be represented as a sum of previous terms of the sequence, and must therefore be the next term. Since each element sj of Sk+1 is equal to 16 ∙ 5k+1 – 3 + 2 j for j {0, 1, 2, 3}, then the difference sj – s1 = (16 ∙ 5k+1 – 3 + 2 j) – (16 ∙ 5k+1 – 3) = 2 j. Because 0 ≤ j ≤ 3, we have 0 ≤ 2 j ≤ 6. With the exception of 1, no number in this interval is in 1 the sequence. However, the difference can’t be 1, because that would imply that j = , which is 2 k+1 not an integer. Therefore, the difference between any element of Sk+1 and 16 ∙ 5 – 3 is not in the sequence, and thus we cannot use 16 ∙ 5k+1 – 3 in a representation of any element of Sk+1. Therefore, each element of Sk+1 cannot be written as a sum of previous terms of the sequence, and is therefore in the sequence. Thus we have shown by induction that the sequence follows the formula stated in the theorem. QED. Figure 6. General Proof for {1, n,...} Sequence Theorem: Define the sequence S = {1, n, ...} by setting the first two terms equal to 1 and n ≥ 4, and then demanding that every integer greater than n be a sum of distinct terms of S. Then this sequence is given by S = {1, n, n + 2} {S i } , i 0 n 1 where Si = {s j } , and sj = axi – b + 2j, where x = , a = n + x + 2, and b = x – 2. 2 j 0 b Proof: By definition, 1 and n are the first two terms in the sequence, and then it is obvious that n + 1 is not in the sequence, but n + 2 is; and since n + 3 = (n + 2) + 1, we also know that n + 3 is not in the sequence. Our first step is to prove that the elements of b S0 = {a b 2 j} j 0 are the next terms of S, i.e., that each element of S0 cannot be represented as a sum of the previous terms of S. We know that for each term sj S0 that we can prove is in the sequence, sj + 1 is not in the sequence. For any two distinct elements of S0, the difference is s j 2 s j1 (a b 2 j 2 ) (a b 2 j1 ) 2( j 2 j1 ) , where 0 ≤ j1 < j2 ≤ b. Then by algebra, we have 0 < j2 – j1 ≤ b – j1. Since b = x – 2 and x ≤ we then have 0 j 2 j1 b j1 b x 2 n 1 , 2 n 1 n3 n 2 , 2 2 2 and then by algebra, we have 0 < 2 (j2 – j1) < n. So the difference of any two elements of S0 must be strictly between 0 and n. The only number in this interval that is represented by the elements of S is 1. But because j1 and j2 are integers, their difference must also be an integer, and therefore the difference of any two elements of S0 must be even, so the difference cannot be 1. Therefore, we can’t use any elements of S0 to represent sj S0, so we must use at least one element of {1, n, n + 2}. The smallest element of S0 is s0 = a – b = n + x + 2 – (x – 2) = n + 4, and the largest element of S0 is sb = a – b + 2 b = a + b = n + x + 2 + (x – 2) = n + 2 x. Since 1 + (n + 2) = n + 3, this is not enough to represent any element of S0. The next smallest sum we can use is n + (n + 2) = 2n + 2. If n is even, then n = 2y for some integer y, and by definition 1 2 y 1 x y y. 2 2 Then by substitution, n + 2x = n + 2y = n + n = 2n < 2n + 2. If n is odd, then n = 2y + 1 for some integer y, and then 2y 2 x y 1 y 1 . 2 Then by substitution, n + 2x = n + 2 (y + 1) = n + 2y + 2 = n + (2y + 1) + 1 = 2n + 1 < 2n + 2. Either way, sb = n + 2x < n + (n + 2), and so the sum of n and n + 2 is too large to represent any element of S0. Therefore, the elements of S0 cannot be represented as sums of previous terms of S, and so these must be the next terms of the sequence. Now define the set Px S S i , and assume that the sequence begins with Pk. We i x 1 now need to show that the next terms of the sequence are the elements of Sk+1. First, we need to show that every integer less than the smallest element of Sk+1 (which is ax – b) can be represented as a sum of distinct terms in the sequence. By definition, we know that every integer up to the largest element of Sk (which is axk + b) inclusive can be represented, so we just need to prove that every integer z for axk + b + 1 ≤ z ≤ axk+1 – b – 1 has a representation. Define the set R (f) as the set of all integers that can be represented as a sum of distinct elements of the set f. Then by definition of the sequence, we have k+1 R (Pk–1) {1} {z: z [n, axk – b – 1]}. We will now attempt to represent other numbers by adding one or more elements of Sk to each of the elements of R (Pk–1). Let Cm = {c j } be the set whose elements are all of the possible sums of m distinct terms of Sk. If we add m terms of Sk, we get maxk – mb + 2 (j1 + j2 + ... + jm) for some distinct ji [0, b]. The smallest element of Cm is maxk – mb + 2 (0 + 1 + 2 + ... m – 1) = maxk – mb + 2 ∙ m( m 1) 2 = maxk – mb + m2 – m, and the largest term of Cm is maxk – mb + 2 [b + (b – 1) + (b – 2) + ... + (b – [m – 1])] = maxk – mb + 2 [mb – m( m 1) ] 2 = maxk – mb + 2mb – m (m – 1) = maxk + mb – m2 + m. m Since we can represent every integer from the smallest possible value of j i 1 i to the largest m possible value of ji , we know that the set Cm represents every integer of the same parity from i 1 maxk – mb + m2 – m to maxk + mb – m2 + m. By adding 1 (the first element of the sequence) to each element of Cm, we can also represent every integer of the same parity from maxk – mb + m2 – m + 1 to maxk + mb – m2 + m + 1. Putting these two intervals together, we have a representation for every number from maxk – mb + m2 – m to maxk + mb – m2 + m + 1, and we will call this interval Am. We can also add each element c j C m to each of the remaining elements of R (Pk–1) to represent each number from cj + n to cj + axk – b – 1. For every cj, we have cj+1 = cj + 2, and then we have (cj + axk – b – 1) – (cj+1 + n) = cj + axk – b – 1 – (cj + 2) – n = cj + (n + x + 2) xk – x + 2 – 1 – cj – 2 – n = nxk + xk+1 + 2xk – x – 1 – n = n (xk – 1) + x (xk – 1) + 2xk – 1 = (n + x) (xk – 1) + 2xk – 1. We know that n + x > 0, and that xk – 1 and 2xk will both increase as k increases. If k = 0, then we have (n + x) (1 – 1) + 2 – 1 = 1 > 0. Therefore, the difference (cj + axk – b – 1) – (cj+1 + n) is always positive, so the interval of representation for each cj intersects the intervals of representation for both the next and previous elements of Cm, so we can combine all of these intervals and find that we have a representation for every number from maxk – mb + m2 – m + n to (maxk + mb – m2 + m) + (axk – b – 1) = (m + 1) axk + (m – 1) b – m2 + m – 1, and we’ll call this interval Bm. If we add only one element of Sk (i.e., the elements of C1) to each element of R (Pk–1), by the formulae proven above, we have representations for every number from axk – b to axk + b + 1 and from axk – b + n to 2axk – 1. Note that axk + b + 1 = axk + x – 1 and that axk – b + n = axk – x + 2 + n. If n is even, then we have axk – b + n = axk – y + 2 + 2y = axk + y + 2 = axk + x + 2. If n is odd, then we have axk – b + n = axk – (y + 1) + 2 + 2y + 1 = axk + y + 2 = axk + x + 1. Putting this information together, we find that we are missing a representation for axk + x, and if n is even, we are also missing a representation for axk + x + 1. Note that b s (ax sSi i b 2 j) j 0 = (b + 1) (axi – b) + 2 b j j 0 b(b 1) 2 i = (b + 1) (ax – b) + b (b + 1) = (b + 1) (axi – b) + 2 ∙ = (b + 1) (axi – b + b) = (b + 1) (axi) = (x – 1) (axi), and then p = 1 + n + (n + 2) + pPk 1 = 2n + 3 + a (x – 1) k 1 s i 0 sS i k 1 x i i 0 xk 1 = 2n + 3 + a (x – 1) x 1 = 2n + 3 + a (xk – 1) = 2n + 3 + (n + x + 2) (xk – 1). If n is odd, then we have p = 2 (2y + 1) + 3 + (2y + 1 + y + 1 + 2) (xk – 1) pPk 1 = 4y + 5 + (3y + 4) (xk – 1) = y + 1 + (3y + 4) + (3y + 4) (xk – 1) = y + 1 + (3y + 4) (1 + xk – 1) = axk + x. If n is even, then we have p = 2 (2y) + 3 + (2y + y + 2) (xk – 1) pPk 1 = 4y + 3 + (3y + 2) (xk – 1) = y + 1 + (3y + 2) + (3y + 2) (xk – 1) = y + 1 + (3y + 2) (1 + xk – 1) = axk + x + 1. Now if n is odd, we have axk + x = = p ; if n is even, we have axk + x = p and axk + x + 1 pPk 1 p. pPk 1 {1} pPk 1 Now if we add b terms of Sk, we have Ab = [(maxk – mb + m2 – m), (maxk + mb – m2 + m + 1)] = [(baxk – b2 + b2 – b), (baxk + b2 – b2 + b + 1)] = [(baxk – x + 2), (baxk + x – 1)] and Bb = [(maxk – mb + m2 – m + n), ([m+1] axk + [m – 1] b – m2 + m – 1)] = [(baxk – b2 + b2 – b + n), ([b + 1] axk + [b – 1] b – b2 + b – 1)] = [(baxk – x + 2 + n), ([x – 1] axk – 1)]. Therefore, we have representations for every number from baxk – x + 2 to baxk + x – 1 and from baxk – x + 2 + n to (x – 1) axk – 1. If n is even, then we have baxk – x + 2 + n = baxk – y + 2 + 2y = baxk + y + 2 = baxk + x + 2, and if n is odd, we have baxk – x + 2 + n = baxk – (y + 1) + 2 + 2y + 1 = baxk + y + 2 = baxk + x + 1. Putting all of this information together, we find that we are missing a representation for baxk + x, and if n is even, we are also missing a representation for baxk + x + 1. We know that (b – 1) axk is an element of Cb–1 and is therefore represented by our sequence. Then if n is odd, we have baxk + x = [(b – 1) axk] + p ; if n is even, we have baxk + x = [(b – 1) axk] + p and baxk + pPk 1 x + 1 = [(b – 1) ax ] + k pPk 1 {1} p. pPk 1 If we add all of the terms of Sk, we get (x – 1) axk. Then if we add this to each element of R (Pk–1), we can represent (x – 1) axk + 1 and every number from (x – 1) axk + n to [(x – 1) axk] + (axk – b – 1) = axk+1 – b – 1. We still need representations for every number from (x – 1) axk + 2 to (x – 1) axk + n – 1 inclusive. If n is odd, then p = axk + x. If we add this to each element of Cb, we have the set pPk 1 b bax j 0 k b b2j p pPk 1 bax k b 2 j ax k x j 0 b x 1ax k x 2 2 j x j 0 ( x 1)ax b = k 2 2 j, j 0 which represents every number of the same parity from (x – 1) axk + 2 to (x – 1) axk + 2b + 2 = (x – 1) axk + 2 (x – 2) + 2 = (x – 1) axk + 2x – 2 = (x – 1) axk + 2 (y + 1) – 2 = (x – 1) axk + 2y = (x – 1) axk + n – 1. By adding p to each element of Cb, we can also represent every number of the same parity pPk 1 {1} from (x – 1) axk + 1 to (x – 1) axk + n – 2. If n is even, then p = axk + x + 1. If we add this to every element of Cb, we have the pPk 1 set b bax j 0 k b2j p bax pPk 1 k b 2 j ax k x 1 b ( x 1)ax k x 2 2 j x 1 j 0 b ( x 1)ax k 3 2 j , j 0 which represents every number of the same parity from (x – 1) axk + 3 to (x – 1) axk + 3 + 2b = (x – 1) axk + 2 (x – 2) + 3 = (x – 1) axk + 2x – 1 = (x – 1) axk + 2y – 1 = (x – 1) axk + n – 1. By adding p to each of the elements of Cb, we can also represent every number of the same pPk 1 {1} parity from (x – 1) axk + 2 to (x – 1) axk + n – 2. If n ≥ 9, then b ≥ 3, and we need to show the numbers that can be represented by adding m terms of Sk for 1 < m < b. If we subtract the smallest element of Bm from the largest element of Am, we get (maxk + mb – m2 + m + 1) – (maxk – mb + m2 – m + n) = 2mb – 2m2 + 2m + 1 – n. We will have a continuous representation if the intervals intersect or are consecutive (i.e., only 1 apart from each other), and this will happen if 2mb – 2m2 + 2m + 1 – n ≥ -1, or if 2mb – 2m2 + 2m + 2 – n ≥ 0. If m = 1, then we have 2mb – 2m2 + 2m + 2 – n = 2b – 2 + 2 + 2 – n = 2b + 2 – n = 2(x – 2) + 2 – n = 2x – 2 – n. n 1 , by algebra we have 2x ≤ n + 1, and then 2x – 2 – n ≤ -1. Therefore, the 2 difference equation is negative for m = 1. If m = 2, then we have 2mb – 2m2 + 2m + 2 – n = 4b – n n 1 n 1 2 2 2 . Then by 8 + 4 + 2 – n = 4b – 2 – n. Note that b = x – 2 = 2 2 2 2 n algebra, we have 4b – 2 – n ≥ 4 2 – 2 – n = 2n – 8 – 2 – n = n – 10. So the difference is 2 non-negative if n ≥ 10. If n = 9, then b = 3, and 4b – 2 – n = 4∙3 – 2 – 9 = 1 > 0, so the difference is also non-negative for n = 9. Since the difference is negative for m = 1 and non-negative for m = 2, then the difference equation has a root for some 1 < m ≤ 2. If m = b, then the difference is Since x ≤ 2b2 – 2b2 + 2b + 2 – n = 2x – 2 – n, which we already proved is negative. If m = b – 1, then the difference is 2mb – 2m2 + 2m + 2 – n = 2 (b – 1) b – 2 (b – 1)2 + 2 (b – 1) + 2 – n = 2b2 – 2b – 2b2 + 4b – 2 + 2b – 2 + 2 – n = 4b – 2 – n, which we already proved is non-negative for n ≥ 9. Since the difference is negative for m = b and non-negative for m = b – 1, then the difference equation has a root for some b – 1 ≤ m < b. Since 2mb – 2m2 + 2m + 2 – n is a quadratic equation, we know that it has no more than two roots, so there are no roots between 2 and b – 1. Therefore, the difference of the largest term of A minus the smallest term of B will remain non-negative for all m from 2 to b – 1 inclusive, and therefore A and B intersect for these values of m, and so we can represent every number from maxk – mb + m2 – m to (m + 1) axk + (m – 1) b – m2 + m – 1 inclusive. Now we must prove that there are no gaps between the intervals of representation for consecutive values of m. If we add m + 1 terms, the smallest possible value of Cm+1 is (m + 1) axk – (m + 1) b + (m + 1)2 – (m + 1) = (m + 1) axk – (m + 1) b + m2 + 2m + 1 – m – 1 = (m + 1) axk – (m + 1) b + m2 + m. If we subtract the smallest element of Am+1 from the largest element of Bm, we get [(m + 1) axk + (m – 1) b – m2 + m – 1] – [(m + 1) axk – (m +1) b + m2 + m] = [(m – 1) + (m + 1)] b – 2m2 – 1 = 2mb – 2m2 – 1. We will have continuous representation over consecutive values of m if this difference is greater than or equal to -1, i.e., if 2mb – 2m2 ≥ 0. We can factor this inequality into 2m (b – m) ≥ 0. This is true if 0 ≤ m ≤ b, which by definition is true. Therefore, there are no gaps between the intervals of representation for consecutive values of m, and thus we have shown that every number less than the smallest element of Sk+1 can be represented as a sum of distinct elements of the sequence. Our next step is to show that each element of Sk+1 cannot be represented by the terms of the sequence up to axk + b. For each element sj Sk+1 that we can prove is in S, we know that sj + 1 is not in the sequence. For any two distinct elements of Sk+1, the difference is s j2 s j1 (ax k 1 b 2 j2 ) (ax k 1 b 2 j2 ) 2( j2 j1 ) , where 0 ≤ j1 < j2 ≤ b. But we already proved in the first paragraph that the difference 2 (j2 – j1) is not represented in the sequence, so we cannot use any elements of Sk+1 to represent other elements of the same set. Now note that if we subtract the sum of the elements of Pk–1 from axk+1 – b, the smallest element of Sk+1, the smallest that the difference can be is (ax k 1 b) p (ax k 1 b) (ax k x 1) pPk 1 = axk+1 – b – axk – x – 1 = xak – x + 2 – axk – x – 1 = (x – 1) axk – 2x + 1 = x [(x – 1) axk–1 – 2] + 1. We know that x ≥ 2, so x – 1 ≥ 1. Since a = n + x + 2 and n ≥ 4, by substitution we have a ≥ 8. 1 Then if k = 0, we have (x – 1) ax-1 ≥ 1 ∙ 8 ∙ = 4 > 2. Therefore, both factors x and [(x – 1) axk–1 2 – 2] are both positive, and since both will remain positive for larger values of x and k, we know that the difference (ax k 1 b) p will be greater than zero. Thus each element of Sk+1 is too pPk 1 large to represent by just the elements of Pk–1, and hence any representation of sj Sk+1 must use at least one element of Sk. b Since Sk = {s } , we know that Sk has b + 1 elements. j Consider the set Cb, the set j 0 whose elements are the possible sums of all but one term of Sk. The largest element of Cb is the largest possible sum of all but one term of Sk, i.e., the sum of all but the smallest term of Sk. This sum is equal to b s (ax k b 2 j) sS k { s0 } j 1 b b(ax k b) 2 j j 1 b(b 1) b(ax k b) 2 2 b(ax k b) b(b 1) b(ax k b b 1) b(ax k 1) bax k b . If we subtract the largest element of Cb from the smallest element of Sk+1, we get (axk+1 – b) – (baxk + b) = axk+1 – b – baxk – b = xaxk – (x – 2) axk – 2 (x – 2) = (x – x + 2) axk – 2x + 4 = 2axk – 2x + 4. Then if n is even, we have [(axk+1 – b) – (baxk + b)] p = (2axk – 2x + 4) – (axk + x + 1) pPk 1 ax k 3x 3 (n x 2) x k 3x 3 (2 y y 2) x k 3 y 3 (3 y 2) x k 3 y 3 As k increases, (3y + 2) xk also increases. If k = 0, we have (3y + 2) – 3y + 3 = 5 > 0. If n is odd, we have [(axk+1 – b) – (baxk + b)] p = (2axk – 2x + 4) – (axk + x) pPk 1 ax k 3x 4 (n x 2) x k 3x 4 (2 y 1 y 1 2) x k 3( y 1) 4 (3 y 4) x k 3 y 1 As k increases, (3y + 4) xk also increases. If k = 0, we have (3y + 4) – 3y + 1 = 5 > 0. In either case, the difference of (axk+1 – b) – (baxk + b) – p is greater than zero. Therefore, if we pPk 1 subtract the largest element of Cb from the smallest element of Sk+1, the difference is too large to represent with just the elements of Pk–1. If we use a smaller element of Cb and/or a larger element of Sk+1, the difference will still be too large to represent using only the elements of Pk–1. Therefore, any representation of an element of Sk+1 must use every element of Sk. We have shown earlier that the sum of all of the terms of Sk is (x – 1) axk. By definition, the jth element of Sk+1 is axk+1 – b + 2j, so when we subtract all of the elements of Sk from any element of Sk+1, we get (axk+1 – b + 2j) – (x – 1) axk = xaxk – b + 2j – (x – 1) axk = (x – x + 1) axk – b + 2j = axk – b + 2j. But (ax k b 2 j ) S k , and by definition of the sequence, this difference cannot be represented as a sum of the elements of Pk–1. Therefore, the elements of Sk+1 cannot be represented as sums of previous terms of the sequence, and hence must be the next terms of the sequence. Thus we have shown by induction that the sequence follows the formula stated in the theorem. QED. Figure 7. Java Code for Sequence Program v. 1.0 /* Sequence Program (Version 1.0) * By Mike Paul * Calculates sequence for 1,n,... * Input: n * Output: Terms of the sequence */ import java.util.Scanner; class Sequence1 { static public void main(String [] args) { Scanner in = new Scanner(System.in); System.out.print("Enter n: "); int n = in.nextInt(); int values[] = new int[22001]; int new_values[] = new int[22001]; System.out.print("1, " + n + ", "); values[1] = 1; values[n] = 1; values[n + 1] = 1; for(int i = n; i < 11001; i++) { if (values[i] == 0) { System.out.print(i + ", "); for (int j = 1; j < 11001; j++) { new_values[j] = values[j]; } for (int k = 1; k < 11001; k++) { if (new_values[k] == 1) values[i + k] = 1; } values[i] = 1; } } } } Figure 8. Sequence Program v. 2.2 /* Sequence Program (Version 2.2) * By Mike Paul * Input: Number of initial terms, range, initial terms, representation counts (y/n) * Output: Sequence, numbers with multiple representations (if desired) * Added: User can turn off representation counts */ import java.util.Scanner; class Sequence_2_2 { static public void main (String [] args) { Scanner in = new Scanner (System.in); System.out.println ("How many initial terms? "); int terms = in.nextInt(); System.out.println ("How far do you want to calculate? "); int range = in.nextInt(); int values[] = new int[2 * range + 1]; int new_values[] = new int[2 * range + 1]; int n[] = new int[terms]; int sum = 0; for (int i = 0; i < terms; i++) { System.out.println ("Enter term # " + i + ": "); n[i] = in.nextInt(); sum = sum + n[i]; } System.out.println ("Display represention counts?"); System.out.println ("1) Yes 2) No"); int option = in.nextInt(); System.out.println(); System.out.println ("The sequence is: "); for (int i = 0; i < terms; i++) { for (int j = 1; j <= sum; j++) { new_values[j] = values[j]; } for (int j = 1; j <= sum; j++) { if (new_values[j] > 0) values[j + n[i]]++; } values[n[i]]++; System.out.print (n[i] + ", "); } for (int i = n[terms - 1]; i < range + 1; i++) { if (values[i] == 0) { System.out.print (i + ", "); for (int j = 1; j <= range; j++) { new_values[j] = values[j]; } for (int j = 1; j <= range; j++) { if (new_values[j] > 0) values[i + j]++; } values[i]++; sum = sum + i; } } if (option == 1) { int highest_sum_count = 1; for (int i = 1; i <= range; i++) { if (values[i] > highest_sum_count) highest_sum_count = values[i]; } int number_count; System.out.println(); if (highest_sum_count > 1) { for (int i = 2; i <= highest_sum_count; i++) { number_count = 0; System.out.println(); for (int j = 1; j <= range; j++) { if (values[j] == i) number_count++; } if (number_count > 0) { System.out.println ("There are " + number_count + " numbers in this range with " + i + " possible representations: "); for (int j = 1; j <= range; j++) { if (values[j] == i) System.out.print (j + ", "); } System.out.println(); } } } else System.out.println ("There are no numbers in this range with multiple representations."); } } } Figure 9. Sequence Program v. 3.12 1 /* Sequence Program (Version 3.12) 2 * Mike Paul 3 * Input: Initial terms, range of calculation, show multiple representations?(y/n) 4 * Output: Sequence, numbers with multiple representations (if desired) 5 * Modifications: 6 * 1) Added a button to print the results on paper, changed the font for the display to 7 * 12-pt. Times New Roman (which is what we've been using previous printouts). 8 * 2) Current Term spinner now automatically changes to match the value of the currently 9 * selected term in the list. 10 * 3) Catches most instances of user entering a limit of calculation over 3,500,000. 11 */ 12 13 import javax.swing.*; 14 import java.awt.event.*; 15 import java.awt.*; 16 import java.awt.print.*; 17 import javax.swing.event.*; 18 19 public class Sequence3_12 extends JFrame implements ActionListener, ListSelectionListener, ChangeListener 20 { 21 public static void main (String [] args) 22 { 23 new Sequence3_12(); 24 } 25 26 JTextArea results; 27 DefaultListModel initial; 28 JList initialTerms; 29 JButton removeTerm, clearTerms, update, addTerm, calculate, clearDisplay, printResults; 30 JSpinner currentTerm, nextTerm, limit, repCount; 31 JCheckBox multRep; 32 JScrollPane initialScroll, resultScroll; 33 final int MAX_LIMIT = 3500000; 34 35 int range, terms, addedTerm, updatedTerm, rCount; 36 37 public Sequence3_12() 38 { 39 this.setTitle("Sequence Program"); 40 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 41 JPanel mainPanel = new JPanel(); 42 mainPanel.setLayout(new GridBagLayout()); 43 44 // List of initial terms 45 46 JPanel initialPanel = new JPanel(); 47 initialPanel.setLayout(new GridLayout(1,0)); 48 initial = new DefaultListModel(); 49 initialTerms = new JList(initial); 50 initialTerms.setVisibleRowCount(10); 51 initialTerms.setSelectionMode(ListSelectionModel.SINGLE_SELECTIO N); 52 initialScroll = new JScrollPane(initialTerms, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, 53 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 54 initialPanel.add(initialScroll); 55 initialPanel.setBorder(BorderFactory.createTitledBorder("Initial Terms")); 56 addItem(mainPanel, initialPanel, 0, 0, 1, 1, GridBagConstraints.WEST, 57 GridBagConstraints.BOTH); 58 initialPanel.setVisible(true); 59 60 // Components to modify or remove terms 61 62 Box changeBox = Box.createVerticalBox(); 63 removeTerm = new JButton("Remove Term"); 64 clearTerms = new JButton("Clear all initial terms"); 65 changeBox.add(removeTerm); 66 changeBox.add(Box.createVerticalStrut(5)); 67 changeBox.add(clearTerms); 68 changeBox.add(Box.createVerticalStrut(10)); 69 Box currentBox = Box.createVerticalBox(); 70 currentTerm = new JSpinner(new SpinnerNumberModel(1, 1, 10000, 1)); 71 update = new JButton("Update Term"); 72 currentBox.add(currentTerm); 73 currentBox.add(Box.createVerticalStrut(10)); 74 currentBox.add(update); 75 currentBox.setBorder(BorderFactory.createTitledBorder("Current Term")); 76 changeBox.add(currentBox); 77 addItem(mainPanel, changeBox, 1, 0, 1, 1, GridBagConstraints.WEST, 78 GridBagConstraints.NONE); 79 80 // Components to add terms 81 82 Box nextBox = Box.createHorizontalBox(); 83 nextBox.add(new JLabel("Next term: ")); 84 nextBox.add(Box.createHorizontalStrut(5)); 85 nextTerm = new JSpinner(new SpinnerNumberModel(1, 1, 10000, 1)); 86 nextBox.add(nextTerm); 87 nextBox.add(Box.createHorizontalStrut(5)); 88 addTerm = new JButton("Add Term"); 89 nextBox.add(addTerm); 90 addItem(mainPanel, nextBox, 0, 1, 2, 1, GridBagConstraints.WEST, 91 GridBagConstraints.NONE); 92 93 // Spinner to set limit of calculation 94 95 Box limitBox = Box.createHorizontalBox(); 96 limitBox.add(new JLabel("Calculate sequence up to ")); 97 limitBox.add(Box.createHorizontalStrut(5)); 98 limit = new JSpinner(new SpinnerNumberModel(10000, 1, MAX_LIMIT, 1)); 99 limitBox.add(limit); 100 limitBox.add(Box.createHorizontalStrut(5)); 101 limitBox.add(new JLabel("(maximum " + MAX_LIMIT + ")")); 102 addItem(mainPanel, limitBox, 0, 3, 2, 1, GridBagConstraints.WEST, 103 GridBagConstraints.NONE); 104 105 // Checkbox to display numbers with multiple representations 106 107 Box multRepBox = Box.createHorizontalBox(); 108 multRep = new JCheckBox("Display numbers with "); 109 multRepBox.add(multRep); 110 multRepBox.add(Box.createHorizontalStrut(5)); 111 repCount = new JSpinner(new SpinnerNumberModel(2, 2, 20, 1)); 112 multRepBox.add(repCount); 113 multRepBox.add(Box.createHorizontalStrut(5)); 114 multRepBox.add(new JLabel(" or more representations")); 115 addItem(mainPanel, multRepBox, 0, 4, 2, 1, GridBagConstraints.WEST, 116 GridBagConstraints.NONE); 117 118 // Button to calculate the sequence 119 120 Box calcBox = Box.createHorizontalBox(); 121 calculate = new JButton("Calculate Sequence"); 122 calcBox.add(calculate); 123 calcBox.add(Box.createHorizontalGlue()); 124 125 // Button to print the results on paper 126 127 printResults = new JButton("Print Results"); 128 calcBox.add(printResults); 129 calcBox.add(Box.createHorizontalGlue()); 130 131 // Button to clear the results display 132 133 clearDisplay = new JButton("Clear Display"); 134 calcBox.add(clearDisplay); 135 addItem(mainPanel, calcBox, 0, 5, 2, 1, GridBagConstraints.WEST, 136 GridBagConstraints.HORIZONTAL); 137 138 // Text field to display the generated sequence 139 140 results = new JTextArea(20, 50); 141 results.setLineWrap(true); 142 results.setWrapStyleWord(true); 143 results.setEditable(false); 144 results.setFont(new Font("Times New Roman", Font.PLAIN, 12)); 145 resultScroll = new JScrollPane(results, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, 146 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 147 addItem(mainPanel, resultScroll, 0, 6, 3, 2, GridBagConstraints.NORTHWEST, 148 GridBagConstraints.BOTH); 149 150 // Put it all together on screen 151 152 this.add(mainPanel); 153 this.pack(); 154 this.setVisible(true); 155 156 /* ActionListeners enable the buttons to actually do stuff when clicked. 157 * addTerm will always be enabled, so it is activated here. 158 * The remove buttons will not be enabled until the user adds initial terms to the list. 159 * printResults and clearDisplay will not be enable until there is text in the results display. 160 */ 161 162 addTerm.addActionListener(this); 163 initialTerms.addListSelectionListener(this); 164 limit.addChangeListener(this); 165 } 166 167 // Position each component on the window 168 169 public void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align, int fill) 170 { 171 GridBagConstraints gc = new GridBagConstraints(); 172 gc.gridx = x; 173 gc.gridy = y; 174 gc.gridwidth = width; 175 gc.gridheight = height; 176 gc.weightx = 100.0; 177 gc.weighty = 100.0; 178 gc.insets = new Insets(5, 5, 5, 5); 179 gc.anchor = align; 180 gc.fill = fill; 181 p.add(c, gc); 182 } 183 184 // Determine which button has been clicked and execute the appropriate action 185 186 public void actionPerformed(ActionEvent e) 187 { 188 terms = initial.size(); 189 190 if (e.getSource() == addTerm) 191 { 192 addedTerm = spinnerValue(nextTerm); 193 addTermToList(addedTerm, terms); 194 } 195 196 else if (e.getSource() == removeTerm) 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 { removeTermFromList(); } else if (e.getSource() == clearTerms) { initial.clear(); turnOffRemoveButtons(); } else if (e.getSource() == update) { updatedTerm = spinnerValue(currentTerm); int i = initialTerms.getSelectedIndex(); removeTermFromList(); addTermToList(updatedTerm, terms - 1); } else if (e.getSource() == calculate) { ChangeEvent ce = new ChangeEvent(limit); if (results.getText().equals("")) { turnOnDisplayButtons(); } boolean calculated = false; while (!calculated) { try { this.calculateSequence(); calculated = true; } catch (OutOfMemoryError m) { limit.setValue(MAX_LIMIT); } } } else if (e.getSource() == clearDisplay) { results.setText(""); turnOffDisplayButtons(); 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 } else if (e.getSource() == printResults) { try { results.print(); } catch (PrinterException p) { JOptionPane.showMessageDialog( this, "Unable to print results.", "Printing Error", JOptionPane.ERROR_MESSAGE); } } } public void valueChanged(ListSelectionEvent s) { if (s.getSource() == initialTerms) { try { int i = initialTerms.getSelectedIndex(); currentTerm.setValue(this.getTerm(i)); } catch (ArrayIndexOutOfBoundsException a) { } } } public void stateChanged(ChangeEvent c) { if (c.getSource() == limit) { try { if (spinnerValue(limit) > MAX_LIMIT) { limit.setValue(MAX_LIMIT); } } catch (OutOfMemoryError m) { 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 limit.setValue(MAX_LIMIT); } } } public void calculateSequence() { String display = ""; range = spinnerValue(limit); rCount = spinnerValue(repCount); int values[] = new int[2 * range + 1]; int newValues[] = new int[2 * range + 1]; int n[] = new int[terms]; int sum = 0; display += "Start with "; for (int i = 0; i < terms; i++) { n[i] = getTerm(i); sum += n[i]; display = display + n[i]; if (i < terms - 1) { display += ", "; } else { display = display + "\n" + "Get "; } } for (int i = 0; i < terms; i++) { for (int j = 1; j <= sum; j++) { newValues[j] = values[j]; } for (int j = 1; j <= sum; j++) { if (newValues[j] > 0) values[j + n[i]]++; } values[n[i]]++; display += (n[i] + ", "); 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 } for (int i = n[terms - 1]; i < range + 1; i++) { if (values[i] == 0) { display += (i + ", "); for (int j = 1; j <= range; j++) { newValues[j] = values[j]; } for (int j = 1; j <= range; j++) { if (newValues[j] > 0) values[i + j]++; } values[i]++; sum = sum + i; } } display += "..."; if (multRep.isSelected()) { int highestSumCount = 1; int numberCount; for (int i = 1; i <= range; i++) { if (values[i] > highestSumCount) highestSumCount = values[i]; } if (highestSumCount >= rCount) { for (int i = rCount; i <= highestSumCount; i++) { numberCount = 0; for (int j = 1; j <= range; j++) { if (values[j] == i) numberCount++; 385 } 386 387 if (numberCount > 0) 388 { 389 display += "\n \n"; 390 display += ("There are " + numberCount + " numbers in this range with " + i + " possible representations: \n"); 391 int counter = 0; 392 393 for (int j = 1; j <= range; j++) 394 { 395 if (values[j] == i) 396 { 397 display += j; 398 counter++; 399 400 if (counter != numberCount) 401 { 402 display += ", "; 403 } 404 } 405 } 406 } 407 } 408 } 409 else 410 { 411 display += "\n \n"; 412 display += ("There are no numbers in this range with " + rCount + " or more representations."); 413 } 414 } 415 416 display += "\n \n"; 417 results.append(display); 418 } 419 420 public int spinnerValue(JSpinner spinner) 421 { 422 String s = spinner.getValue().toString(); 423 return Integer.parseInt(s); 424 } 425 426 public int getTerm(int i) 427 { 428 String s = initial.get(i).toString(); 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 return Integer.parseInt(s); } public void addTermToList(int addedTerm, int terms) { if (terms == 0) { initial.addElement(addedTerm); turnOnRemoveButtons(); initialTerms.setSelectedIndex(0); } else { if (addedTerm > getTerm(terms - 1)) { initial.addElement(addedTerm); initialTerms.setSelectedIndex(terms); } else { for (int i = 0; i < terms; i++) { if (addedTerm < getTerm(i)) { initial.add(i, addedTerm); initialTerms.setSelectedIndex(i); break; } else if (addedTerm == getTerm(i)) { break; } } } } } public void removeTermFromList() { int i = initialTerms.getSelectedIndex(); initial.remove(i); if (i == terms - 1) { initialTerms.setSelectedIndex(i - 1); } 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 } else { initialTerms.setSelectedIndex(i); } if (terms == 1) { turnOffRemoveButtons(); } } public void turnOffRemoveButtons() { removeTerm.removeActionListener(this); clearTerms.removeActionListener(this); update.removeActionListener(this); calculate.removeActionListener(this); } public void turnOnRemoveButtons() { removeTerm.addActionListener(this); clearTerms.addActionListener(this); update.addActionListener(this); calculate.addActionListener(this); } public void turnOffDisplayButtons() { clearDisplay.removeActionListener(this); printResults.removeActionListener(this); } public void turnOnDisplayButtons() { clearDisplay.addActionListener(this); printResults.addActionListener(this); } Figure 10. Screen Shot of Sequence Program v. 3.12 Figure 11. Sequences beginning with {1, 2, n,...} Start with 1, 2, 5 Get 1, 2, 5, 9, 13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656, ... Start with 1, 2, 6 Get 1, 2, 6, 10, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, ... Start with 1, 2, 7 Get 1, 2, 7, 11, 15, 30, 60, 120, 240, 480, 960, 1920, 3840, 7680, ... Start with 1, 2, 8 Get 1, 2, 8, 12, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, ... Start with 1, 2, 9 Get 1, 2, 9, 13, 17, 21, 55, 59, 169, 173, 511, 515, 1537, 1541, 4615, 4619, ... Start with 1, 2, 10 Get 1, 2, 10, 14, 18, 22, 58, 62, 178, 182, 538, 542, 1618, 1622, 4858, 4862, ... Start with 1, 2, 11 Get 1, 2, 11, 15, 19, 23, 61, 65, 187, 191, 565, 569, 1699, 1703, 5101, 5105, ... Start with 1, 2, 12 Get 1, 2, 12, 16, 20, 24, 64, 68, 196, 200, 592, 596, 1780, 1784, 5344, 5348, ... Start with 1, 2, 13 Get 1, 2, 13, 17, 21, 25, 29, 96, 100, 104, 396, 400, 404, 1596, 1600, 1604, 6396, 6400, 6404, ... Start with 1, 2, 14 Get 1, 2, 14, 18, 22, 26, 30, 100, 104, 108, 412, 416, 420, 1660, 1664, 1668, 6652, 6656, 6660, ... Start with 1, 2, 15 Get 1, 2, 15, 19, 23, 27, 31, 104, 108, 112, 428, 432, 436, 1724, 1728, 1732, 6908, 6912, 6916, ... Start with 1, 2, 16 Get 1, 2, 16, 20, 24, 28, 32, 108, 112, 116, 444, 448, 452, 1788, 1792, 1796, 7164, 7168, 7172, ... Start with 1, 2, 17 Get 1, 2, 17, 21, 25, 29, 33, 37, 149, 153, 157, 161, 769, 773, 777, 781, 3869, 3873, 3877, 3881, ... Start with 1, 2, 18 Get 1, 2, 18, 22, 26, 30, 34, 38, 154, 158, 162, 166, 794, 798, 802, 806, 3994, 3998, 4002, 4006, ... Figure 12. Sequences beginning with {2, n,...} Start with 2, 3 Get 2, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 Start with 2, 4 Get 2, 4, 5, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 Start with 2, 5 Get 2, 5, 6, 9, 10, 28, 29, 85, 86, 256, 257, 769, 770, 2308, 2309, 6925, 6926 Start with 2, 6 Get 2, 6, 7, 10, 11, 14, 45, 46, 49, 185, 186, 189, 745, 746, 749, 2985, 2986, 2989 Start with 2, 7 Get 2, 7, 8, 11, 12, 16, 50, 51, 55, 206, 207, 211, 830, 831, 835, 3326, 3327, 3331 Start with 2, 8 Get 2, 8, 9, 12, 13, 16, 53, 54, 57, 217, 218, 221, 873, 874, 877, 3497, 3498, 3501 Start with 2, 9 Get 2, 9, 10, 13, 14, 17, 18, 75, 76, 79, 80, 385, 386, 389, 390, 1935, 1936, 1939, 1940, 9685, 9686, 9689, 9690 Start with 2, 10 Get 2, 10, 11, 14, 15, 18, 19, 22, 102, 103, 106, 107, 110, 630, 631, 634, 635, 638, 3798, 3799, 3802, 3803, 3806 Start with 2, 11 Get 2, 11, 12, 15, 16, 19, 20, 24, 109, 110, 113, 114, 118, 673, 674, 677, 678, 682, 4057, 4058, 4061, 4062, 4066 Start with 2, 12 Get 2, 12, 13, 16, 17, 20, 21, 24, 114, 115, 118, 119, 122, 702, 703, 706, 707, 710, 4230, 4231, 4234, 4235, 4238 Start with 2, 13 Get 2, 13, 14, 17, 18, 21, 22, 25, 26, 146, 147, 150, 151, 154, 155, 1049, 1050, 1053, 1054, 1057, 1058, 7370, 7371, 7374, 7375, 7378, 7379 Start 2, 14 Get 2, 14, 15, 18, 19, 22, 23, 26, 27, 30, 183, 184, 187, 188, 191, 192, 195, 1503, 1504, 1507, 1508, 1511, 1512, 1515, 12063, 12064, 12067, 12068, 12071, 12072, 12075 Start with 2, 15 Get 2, 15, 16, 19, 20, 23, 24, 27, 28, 32, 192, 193, 196, 197, 200, 201, 205, 1576, 1577, 1580, 1581, 1584, 1585, 1589, 12648, 12649, 12652, 12653, 12656, 12657, 12661 Figure 13. Sequences Beginning with {n, n + 1} Start with 1, 2 Get 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 Start with 2, 3 Get 2, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 Start with 3, 4 Get 3, 4, 5, 6, 16, 17, 49, 50, 148, 149, 445, 446, 1336, 1337, 4009, 4010 Start with 4, 5 Get 4, 5, 6, 7, 8, 27, 28, 29, 111, 112, 113, 447, 448, 449, 1791, 1792, 1793, 7167, 7168, 7169 Start with 5, 6 Get 5, 6, 7, 8, 9, 10, 41, 42, 43, 44, 211, 212, 213, 214, 1061, 1062, 1063, 1064, 5311, 5312, 5313, 5314 Start with 6, 7 Get 6, 7, 8, 9, 10, 11, 12, 58, 59, 60, 61, 62, 358, 359, 360, 361, 362, 2158, 2159, 2160, 2161, 2162 Start with 7, 8 Get 7, 8, 9, 10, 11, 12, 13, 14, 78, 79, 80, 81, 82, 83, 561, 562, 563, 564, 565, 566, 3942, 3943, 3944, 3945, 3946, 3947 Start with 8, 9 Get 8, 9, 10, 11, 12, 13, 14, 15, 16, 101, 102, 103, 104, 105, 106, 107, 829, 830, 831, 832, 833, 834, 835, 6653, 6654, 6655, 6656, 6657, 6658, 6659 Start with 9, 10 Get 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 127, 128, 129, 130, 131, 132, 133, 134, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178 Start with 10, 11 Get 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 156, 157, 158, 159, 160, 161, 162, 163, 164, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604 Start with 11, 12 Get 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122 Start with 12, 13 Get 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741 Figure 14. Proof for {n, n + 1,...} Sequences Theorem: Define the sequence S = {n, n + 1, ...} by setting the first two terms equal to n and n + 1, where n ≥ 2, and then demanding that every integer greater than n + 1 be a sum of distinct terms of S. Then this sequence is given by: S = {n, n + 1} {S i } , i 0 n2 3n 2 j , where a where S i {si , j } , and si , j an i . 2 2 j 0 Proof: By definition, n and n + 1 are the first two terms of the sequence. Our first step is to n2 n2 j} are in the next terms of the sequence, i.e., that prove that the elements of S0 = {a 2 j 0 each element of S0 cannot be represented as a sum of previous terms of S. For any two distinct elements of S0, the difference is: n2 n2 s 0, j2 s 0, j1 (a j 2 ) (a j1 ) j 2 j1 , 2 2 where 0 ≤ j1 < j2 ≤ n – 2 < n. Then by algebra, we have 0 < j2 – j1 ≤ n – 2 – j1 < n. Therefore, the difference is an integer less than n, which by definition is not in the sequence. Therefore, we cannot represent an element of S0 using other elements of S0. We know that the elements of S0 are the integers from n2 3n 2 n 2 s 0, 0 a 0 n2 2 2 2 n2 3n 2 n 2 (n 2) 2n . to s 0,n 2 a 2 2 2 n2 Since the sum of the first two terms of S is 2n + 1, we know that each integer from n + 2 to 2n cannot be represented as a sum of either of the first two terms in the sequence. Therefore, the elements of S0 cannot be represented as sums of the previous terms of S, and must therefore be the next terms of the sequence. Now define the set Px S {S } , and assume that the sequence begins with Pk for i i x 1 some k ≥ 0. We now need to show that the next terms of the sequence are the elements of Sk+1. First, we need to show that every integer less than the smallest element of Sk+1, which n2 is an k 1 , can be represented as a sum of distinct terms of S. By definition, we know that 2 n2 every integer up to and including the largest element of Sk, an k , can be represented, so 2 n2 n n2 1 an k to an k 1 1 we just need to prove that every integer from an k 2 2 2 n an k 1 can be represented. Define the set R (f) as the set of all integers that can be 2 represented as a sum of distinct elements of the set f. Then by definition of the sequence, we n have R (Pk–1) {z: z [n, an k ]}. We will now attempt to represent other numbers by 2 adding one or more elements of Sk to each element of R (Pk–1). Let Cm be the set whose elements are all of the possible sums of m distinct terms of Sk. If we add m terms of Sk, we get n2 man k m ( j1 j 2 ... j m ) for distinct ji [0, n – 2]. The smallest element of Cm is: 2 n2 n 2 m(m 1) k man k m (0 1 2 ... m 1) man m 2 2 2 m 1 n 2 man k m 2 2 m 1 n 2 man k m 2 m n 1 = man k m , 2 and the largest term of Cm is: n2 man k m (n 2) (n 2 1) (n 2 2) ... (n 2 [m 1]) 2 m(m 1) n2 man k m m(n 2) 2 2 n2 n2 m 1 man k m 2m m 2 2 2 n2 m 1 man k m m 2 2 n 2 m 1 man k m 2 n m 1 man k m . 2 m Since j i 1 i can represent every integer from its minimum value to its maximum value, we know m n 1 n m 1 k that Cm represents every integer from man k m to man m . By adding 2 2 each element cj of Cm to each element of R (Pk–1), we can also represent every number from cj n + n to c j an k . Since the elements of Cm are consecutive, the intervals of representation for 2 each element of Cm intersect, so we can combine these intervals and find that we have a m n 1 n m 1 k representation for every number from man k m n to man m 2 2 n n m 1 n an k (m 1)an k m , and we will call this interval Bm. 2 2 2 If we add only one element of Sk (i.e., the elements of C1) to each element of R( Pk 1 ) , by n2 the formulae proven above, we have representations for every number from an k to 2 n2 n2 n 11 n an k n to 2an k 2an k 1 . Note that and from an k 2 2 2 2 n 2 n 2 2n an k n an k 2 2 2 2 n 2 an k 2 n 24 an k 2 n 2 an k 2. 2 n2 1 . Note that Then we find that we find that we are missing a representation for an k 2 n2 n2 s (an i j) 2 sSi j 0 (n 1)( n 2) (n 2)( n 1) (n 1)an i 2 2 i (n 1)an , and then k 1 p n (n 1) s pPk 1 i 0 sSi k 1 2n 1 (n 1)an i i 0 k 1 2n 1 (n 1)a n i i 0 nk 1 2n 1 (n 1)a n 1 k 2n 1 a (n 1) 2n 1 an k a 4n 2 3n 2 an k 2 2 n an k 2 n 2 2 an k 2 2 2 n2 an k 1. 2 Now if n ≥ 4, we can add n – 2 terms of Sk; this is the same as adding all but one term of Sk, so we can obtain the elements of Cn–2 by subtracting each element of Sk from the sum of all of the elements of Sk: n2 n2 n2 n2 C n 2 (n 1)an k (an k j ) (n 2)an k j 2 2 j 0 j 0 By evaluating the values of this set, we find that we have representations for every number from n2 n2 (n 2)an k to (n 2)an k . If we add each element of Cn–2 to each element 2 2 n2 n2 n (n 2)an k 2 of R( Pk 1 ) , we can represent every number from (n 2)an k 2 2 n2 n to (n 2)an k + an k (n 1)an k 1. However, we are missing a representation 2 2 n 2 1 . We know that (n 3)an k is an element of C n 3 and is therefore for (n 2)an k 2 n2 represented by the sequence. Then we have (n 2)an k 1 (n 3)an k p . 2 pPk 1 If we add all of the terms of Sk, we get (n 1)an k . Then if we add this to each element n of R( Pk 1 ) , we can represent every number from (n 1)an k n to (n 1)an k an k 2 n n nan k an k 1 . We still need representations for every number from (n 1)an k 1 2 2 n2 n2 n k j an k to (n 1)an n 1. Note that c p (n 2)an k 2 2 pPk 1 cC n 2 j 0 n2 (n 1)an k n 1 j. Therefore, by adding j 0 p to each element of C pPk 1 n2 , we can represent every number from (n 1)an k 1 to (n 1)an k n 1. If n ≥ 5, then n – 2 ≥ 3, and we need to show the numbers that can be represented by adding m terms of Sk for 1 < m < n – 2. If we subtract the smallest element of Bm from the largest element of Cm, we get n m 1 m n 1 n m 1 m n 1 k k man m n m m n man m 2 2 2 2 m (n m 1 m n 1) n 2 m (2n 2m 2) n 2 mn m 2 m n . We will have a continuous representation if the intervals Cm and Bm intersect or are consecutive (i.e., only 1 apart from each other), and this will happen if mn – m2 – m – n ≥ -1, or if mn – m2 – m – n + 1 ≥ 0. If m = 1, then we have mn – m2 – m – n + 1 = n – 1 – 1 – n + 1 = -1 < 0, so the difference equation is negative for m = 1. If m = 2, then we have mn – m2 – m – n + 1 = 2n – 4 – 2 – n + 1 = n – 5, so the difference is non-negative for n ≥ 5. Since the difference is negative for m = 1 and non-negative for m = 2, then the difference equation has a root for some 1 < m ≤ 2. If m = n – 2, then the difference is (n – 2) n – n – (n – 2)2 – (n – 2) + 1 = n2 – 2n – n – n2 + 4n – 4 – n + 2 + 1 = -1 < 0, so the difference is negative for m = n – 2. If m = n – 3, then the difference is (n – 3) n – n – (n – 3)2 – (n – 3) + 1 = n2 – 3n – n – n2 + 6n – 9 – n + 3 + 1 = n – 5, which is nonnegative for n ≥ 5. Since the difference is negative for m = n – 2 and non-negative for m = n – 3, then the difference equation has a root for some n – 3 ≤ m < n – 2. Since mn – m2 – m – n + 1 is a quadratic equation in m, we know that it has no more than two roots, so there are no roots between 2 and n – 3. Therefore, the difference of the largest term of Cm minus the largest term of Bm will be non-negative for all m from 2 to n – 3 inclusive, and therefore Cm and Bm intersect m n 1 for these values of m, and so we can represent every number from man k m to 2 n m 1 n (m 1)an k m inclusive. 2 2 Now if n ≥ 3, we must prove that there are no gaps between the intervals of representation for consecutive values of m. If we add m + 1 terms, the smallest possible value of mn 2 Cm is (m 1)an k (m 1) . If we subtract the smallest element of Cm+1 from the 2 largest element of Bm, the difference is n m 1 n m n 2 k k (m 1)an (m 1) (m 1)an m 2 2 2 n m 1 n mn 2 m (m 1) 2 2 2 mn m 2 m n m(m n 2) (m n 2) 2 2 2 mn m m n m mn 2m m n 2 2 2 2mn 2m 4m 2 2 2 mn m 2m 1 . We will have continuous representation over consecutive values of m if this difference is greater than or equal to -1, i.e., if mn – m2 – 2m ≥ 0. We can factor this inequality into m (n – m – 2) ≥ 0. This is true if 0 ≤ m ≤ n – 2, which by definition is true because Si has n – 1 elements. Therefore, there are no gaps between the intervals of representation for consecutive values of m, and thus we have shown that every number less than the smallest element of Sk+1 can be represented as a sum of distinct elements of the sequence. Our next step is to show that each element of Sk+1 cannot be represented by the terms of n2 the sequence up to an k . For any two distinct elements of Sk+1, the difference is 2 n2 k 1 n 2 j 2 an k 1 j1 j 2 j1 , where 0 ≤ j1 < j2 ≤ n – 2 < n. But we an 2 2 already proved in the first paragraph that the difference j2 – j1 is not represented in the sequence, so we cannot represent an element of Sk+1 using other elements of Sk+1. First, note that since we have n2 n an k 1 j > an k p , 2 2 pPk 1 any representation of an element of Sk+1 must use at least one element of Sk. Consider the set C n 2 , the set whose elements are the possible sums of all but one term of Sk. If we subtract the largest element of C n 2 from the smallest element of Sk+1, we get n 2 n2 n2 k 1 n 2 k k k an 2 (n 2)an 2 nan 2 (n 2)an 2 [n (n 2)]an k (n 2) 2an k n 2 . n 2 n 2 n (n 2)an k p 2an k n 2 an k Then we have an k 1 2 2 pPk 1 2 an k 3n 2 2 3n 3n 3n 2 3n 4 2 increases. If k = 0, we have a 2 = 3 > 0. 2 2 2 2 2 Therefore, if we subtract the largest element of C n 2 from the smallest element of Sk+1, the difference is too large to represent with just the elements of Pk–1. If we use a larger element of Sk+1 and/or a smaller element of C n 2 , the difference will still be too large to represent using only the elements of Pk–1. Therefore, any representation of an element of Sk+1 must use every element of Sk. We have shown earlier that the sum of all of the terms of Sk is (n – 1) ank. By definition, n2 j , so when we subtract all of the elements of Sk from any the jth element of Sk+1 is an k 1 2 element of Sk+1, we get n2 k 1 n 2 j (n 1)an k nan k j (n 1)an k an 2 2 n2 [n (n 1)]an k j 2 n2 an k j. 2 n2 j S k , and by definition of the sequence, this difference cannot be But an k 2 represented as a sum of the elements of Pk–1. Therefore, the elements of Sk+1 cannot be represented as sums of previous terms of the sequence, and hence must be the next terms of the sequence. Thus we have shown by induction that the sequence follows the formula stated in the theorem. QED. As k increases, an k Figure 15. Sequences Beginning with {n, n + 2} Start with 1, 3 Get 1, 3, 5, 7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, ... Start with 2, 4 Get 2, 4, 5, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, ... Start with 3, 5 Get 3, 5, 6, 7, 17, 19, 53, 55, 161, 163, 485, 487, 1457, 1459, 4373, 4375, 13121, 13123, ... Start with 4, 6 Get 4, 6, 7, 8, 9, 29, 31, 32, 121, 123, 124, 489, 491, 492, 1961, 1963, 1964, 7849, 7851, 7852, ... Start with 5, 7 Get 5, 7, 8, 9, 10, 11, 44, 46, 47, 48, 229, 231, 232, 233, 1154, 1156, 1157, 1158, 5779, 5781, 5782, 5783, ... Start with 6, 8 Get 6, 8, 9, 10, 11, 12, 13, 62, 64, 65, 66, 67, 386, 388, 389, 390, 391, 2330, 2332, 2333, 2334, 2335, 13994, 13996, 13997, 13998, 13999, ... Start with 7, 9 Get 7, 9, 10, 11, 12, 13, 14, 15, 83, 85, 86, 87, 88, 89, 601, 603, 604, 605, 606, 607, 4227, 4229, 4230, 4231, 4232, 4233, ... Start with 8, 10 Get 8, 10, 11, 12, 13, 14, 15, 16, 17, 107, 109, 110, 111, 112, 113, 114, 883, 885, 886, 887, 888, 889, 890, 7091, 7093, 7094, 7095, 7096, 7097, 7098, ... Start with 9, 11 Get 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 134, 136, 137, 138, 139, 140, 141, 142, 1241, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 11204, 11206, 11207, 11208, 11209, 11210, 11211, 11212, ... Start with 10, 12 Get 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 164, 166, 167, 168, 169, 170, 171, 172, 173, 1684, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 16884, 16886, 16887, 16888, 16889, 16890, 16891, 16892, 16893, ... Start with 11, 13 Get 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 197, 199, 200, 201, 202, 203, 204, 205, 206, 207, 2221, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, ... Start with 12, 14 Get 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 233, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 2861, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, ... Figure 16. Sequences beginning with {n, n + 3} Start with 1, 4 Get 1, 4, 6, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, ... Start with 2, 5 Get 2, 5, 6, 9, 10, 28, 29, 85, 86, 256, 257, 769, 770, 2308, 2309, 6925, 6926, ... Start with 3, 6 Get 3, 6, 7, 8, 12, 31, 32, 94, 95, 283, 284, 850, 851, 2551, 2552, 7654, 7655, ... Start with 4, 7 Get 4, 7, 8, 9, 10, 32, 33, 35, 132, 133, 135, 532, 533, 535, 2132, 2133, 2135, 8532, 8533, 8535, ... Start with 5, 8 Get 5, 8, 9, 10, 11, 12, 48, 49, 51, 52, 248, 249, 251, 252, 1248, 1249, 1251, 1252, 6248, 6249, 6251, 6252, ... Start with 6, 9 Get 6, 9, 10, 11, 12, 13, 14, 67, 68, 70, 71, 72, 415, 416, 418, 419, 420, 2503, 2504, 2506, 2507, 2508, ... Start with 7, 10 Get 7, 10, 11, 12, 13, 14, 15, 16, 89, 90, 92, 93, 94, 95, 642, 643, 645, 646, 647, 648, 4513, 4514, 4516, 4517, 4518, 4519, ... Start with 8, 11 Get 8, 11, 12, 13, 14, 15, 16, 17, 18, 114, 115, 117, 118, 119, 120, 121, 938, 939, 941, 942, 943, 944, 945, 7530, 7531, 7533, 7534, 7535, 7536, 7537, ... Start with 9, 12 Get 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 142, 143, 145, 146, 147, 148, 149, 150, 1312, 1313, 1315, 1316, 1317, 1318, 1319, 1320, ... Start with 10, 13 Get 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 173, 174, 176, 177, 178, 179, 180, 181, 182, 1773, 1774, 1776, 1777, 1778, 1779, 1780, 1781, 1782, ... Start with 11, 14 Get 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 207, 208, 210, 211, 212, 213, 214, 215, 216, 217, 2330, 2331, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, ... Start with 12, 15 Get 12, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 244, 245, 247, 248, 249, 250, 251, 252, 253, 254, 255, 2992, 2993, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, ... Figure 17. Sequences beginning with {n, n + 4} Start with 1, 5 Get 1, 5, 7, 9, 11, 29, 31, 89, 91, 269, 271, 809, 811, 2429, 2431, 7289, 7291, ... Start with 2, 6 Get 2, 6, 7, 10, 11, 14, 45, 46, 49, 185, 186, 189, 745, 746, 749, 2985, 2986, 2989, ... Start with 3, 7 Get 3, 7, 8, 9, 13, 14, 48, 49, 50, 195, 196, 197, 783, 784, 785, 3135, 3136, 3137, ... Start with 4, 8 Get 4, 8, 9, 10, 11, 16, 51, 52, 53, 207, 208, 209, 831, 832, 833, 3327, 3328, 3329, ... Start with 5, 9 Get 5, 9, 10, 11, 12, 13, 52, 53, 54, 56, 267, 268, 269, 271, 1342, 1343, 1344, 1346, 6717, 6718, 6719, 6721, ... Start with 6, 10 Get 6, 10, 11, 12, 13, 14, 15, 72, 73, 74, 76, 77, 444, 445, 446, 448, 449, 2676, 2677, 2678, 2680, 2681, ... Start with 7, 11 Get 7, 11, 12, 13, 14, 15, 16, 17, 95, 96, 97, 99, 100, 101, 683, 684, 685, 687, 688, 689, 4799, 4800, 4801, 4803, 4804, 4805, ... Start with 8, 12 Get 8, 12, 13, 14, 15, 16, 17, 18, 19, 121, 122, 123, 125, 126, 127, 128, 993, 994, 995, 997, 998, 999, 1000, 7969, 7970, 7971, 7973, 7974, 7975, 7976, ... Start with 9, 13 Get 9, 13, 14, 15, 16, 17, 18, 19, 20, 21, 150, 151, 152, 154, 155, 156, 157, 158, 1383, 1384, 1385, 1387, 1388, 1389, 1390, 1391, ... Start with 10, 14 Get 10, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 182, 183, 184, 186, 187, 188, 189, 190, 191, 1862, 1863, 1864, 1866, 1867, 1868, 1869, 1870, 1871, ... Start with 11, 15 Get 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 2439, 2440, 2441, 2443, 2444, 2445, 2446, 2447, 2448, 2449, ... Start with 12, 16 Get 12, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 255, 256, 257, 259, 260, 261, 262, 263, 264, 265, 266, 3123, 3124, 3125, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, ... Figure 18. Sequences beginning with {n, n + 5} Start with 1, 6 Get 1, 6, 8, 10, 12, 32, 34, 98, 100, 296, 298, 890, 892, 2672, 2674, 8018, 8020, ... Start with 2, 7 Get 2, 7, 8, 11, 12, 16, 50, 51, 55, 206, 207, 211, 830, 831, 835, 3326, 3327, 3331, ... Start with 3, 8 Get 3, 8, 9, 10, 14, 15, 16, 68, 69, 70, 74, 349, 350, 351, 355, 1754, 1755, 1756, 1760, 8779, 8780, 8781, 8785, ... Start with 4, 9 Get 4, 9, 10, 11, 12, 17, 18, 73, 74, 75, 76, 371, 372, 373, 374, 1861, 1862, 1863, 1864, 9311, 9312, 9313, 9314, ... Start with 5, 10 Get 5, 10, 11, 12, 13, 14, 20, 76, 77, 78, 79, 386, 387, 388, 389, 1936, 1937, 1938, 1939, 9686, 9687, 9688, 9689, ... Start with 6, 11 Get 6, 11, 12, 13, 14, 15, 16, 77, 78, 79, 80, 82, 473, 474, 475, 476, 478, 2849, 2850, 2851, 2852, 2854, ... Start with 7, 12 Get 7, 12, 13, 14, 15, 16, 17, 18, 101, 102, 103, 104, 106, 107, 724, 725, 726, 727, 729, 730, 5085, 5086, 5087, 5088, 5090, 5091, ... Start with 8, 13 Get 8, 13, 14, 15, 16, 17, 18, 19, 20, 128, 129, 130, 131, 133, 134, 135, 1048, 1049, 1050, 1051, 1053, 1054, 1055, 8408, 8409, 8410, 8411, 8413, 8414, 8415, ... Start with 9, 14 Get 9, 14, 15, 16, 17, 18, 19, 20, 21, 22, 158, 159, 160, 161, 163, 164, 165, 166, 1454, 1455, 1456, 1457, 1459, 1460, 1461, 1462, ... Start with 10, 15 Get 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 191, 192, 193, 194, 196, 197, 198, 199, 200, 1951, 1952, 1953, 1954, 1956, 1957, 1958, 1959, 1960, ... Start with 11, 16 Get 11, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 227, 228, 229, 230, 232, 233, 234, 235, 236, 237, 2548, 2549, 2550, 2551, 2553, 2554, 2555, 2556, 2557, 2558, ... Start with 12, 17 Get 12, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 266, 267, 268, 269, 271, 272, 273, 274, 275, 276, 277, 3254, 3255, 3256, 3257, 3259, 3260, 3261, 3262, 3263, 3264, 3265, ... Figure 19. Beta Sequences, or sequences beginning with {n, 2n,...} Start with 1, 2 Get 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, ... Start with 2, 4 Get 2, 4, 5, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, ... Start with 3, 6 Get 3, 6, 7, 8, 12, 31, 32, 94, 95, 283, 284, 850, 851, 2551, 2552, 7654, 7655, ... Start with 4, 8 Get 4, 8, 9, 10, 11, 16, 51, 52, 53, 207, 208, 209, 831, 832, 833, 3327, 3328, 3329, ... Start with 5, 10 Get 5, 10, 11, 12, 13, 14, 20, 76, 77, 78, 79, 386, 387, 388, 389, 1936, 1937, 1938, 1939, 9686, 9687, 9688, 9689, ... Start with 6, 12 Get 6, 12, 13, 14, 15, 16, 17, 24, 106, 107, 108, 109, 110, 646, 647, 648, 649, 650, 3886, 3887, 3888, 3889, 3890, ... Start with 7, 14 Get 7, 14, 15, 16, 17, 18, 19, 20, 28, 141, 142, 143, 144, 145, 146, 1002, 1003, 1004, 1005, 1006, 1007, 7029, 7030, 7031, 7032, 7033, 7034, ... Start with 8, 16 Get 8, 16, 17, 18, 19, 20, 21, 22, 23, 32, 181, 182, 183, 184, 185, 186, 187, 1469, 1470, 1471, 1472, 1473, 1474, 1475, ... Start with 9, 18 Get 9, 18, 19, 20, 21, 22, 23, 24, 25, 26, 36, 226, 227, 228, 229, 230, 231, 232, 233, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, ... Start with 10, 20 Get 10, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 40, 276, 277, 278, 279, 280, 281, 282, 283, 284, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, ... Figure 20. Proof of Formula for Beta Sequences Theorem: Define the sequence S = {n, 2n,...} by setting the first two terms equal to n and 2n for n ≥ 2, and then requiring that every integer greater than 2n be a sum of distinct terms of S. Then this sequence is given by S = {n, 2n, 2n + 1, 2n + 2, ..., 3n – 1, 4n} S i i 0 n2 where S i {si , j } , and si , j an i j 0 n2 5n 6n j , where a . 2 2 2 Proof: By definition, n and 2n are the first two terms of the sequence, and their sum is 3n, so any number between 2n and 3n cannot be represented using only these two terms. For any two distinct numbers 2n + r1 and 2n + r2, the difference is (2n + r2) – (2n + r1) = r2 – r1, where 0 ≤ r1 < r2 < n. Then by algebra, we have 0 < r2 – r1 < n – r1 ≤ n, so the difference is less than n. But no number less than n exists in the sequence, so we cannot represent any number from 2n to 3n – 1 using any other such numbers. Therefore, the numbers from 2n + 1 to 3n – 1 cannot be represented by adding previous terms in the sequence, and must therefore be the next terms of S. Then by adding n to any number from 2n to 3n – 1, we can represent every number from 3n to 4n – 1, so these numbers are not in the sequence. We now need to show that 4n cannot be represented as a sum of any of the previous terms of the sequence. If we try adding n and 2n + r for 0 ≤ r ≤ n – 1, the sum is at most 4n – 1, which is too small to represent 4n. If we try adding any 2n + r terms, the sum is at least 2n + (2n + 1) = 4n + 1, which is too large to represent 4n. Any sum of three terms is at least n + 2n + (2n + 1) = 5n + 1, which is also too large to represent 4n. Therefore, we cannot represent 4n as a sum of previous terms of the sequence, and thus 4n is the next term. n2 n 1 = a can 2 2 be represented by adding distinct terms of S. Let Dm be the set of all numbers that can be represented by adding m distinct numbers in the interval [2n, 3n – 1] = [2n, 2n + n – 1] for any m such that 1 ≤ m ≤ n, and let Em be the set of all numbers equal to n plus any element of Dm. If we add m terms of the above interval, we get (2n + r1) + (2n + r2) + ... + (2n + m) = 2mn + r1 + r2 + m(m 1) ... + rm. Then the smallest element of Dm is 2mn 0 1 2 ... m 1 2mn , 2 m(m 1) and the largest element of Dm is 2mn (n 1) (n 2) ... (n m) 2mn mn 2 m(m 1) 3mn . Since r1 + r2 + ... + rm can represent every integer from its minimum value to 2 m(m 1) its maximum value, we know that Dm represents every number from 2mn to 2 m(m 1) m(m 1) 3mn n to , and then Em represents every number from 2mn 2 2 m(m 1) 3mn n. 2 We next need to show that every number from 2n to s0,0 – 1 = a Lemma 1: For any value of m such that 1 ≤ m ≤ n – 1, there is continuous representation from Dm to Em (i.e., Dm and Em either intersect or are consecutive). Proof: We need to show that for the above values of m, when we subtract the smallest element of Em from the largest element of Dm, the difference is greater than or equal to -1. So we will have continuous representation if m(m 1) m(m 1) 2mn n 1 . 3mn 2 2 Then by algebra, we have m2 m m2 m 3mn 2mn n 1 2 2 m2 m m2 m mn n 1 0 2 2 2 2 2 mn m n 1 0 n(m 1) (m 2 1) 0 n(m 1) (m 1)( m 1) 0 (n 1 m)( m 1) 0 This inequality is true if 1 ≤ m ≤ n – 1. QED. Lemma 2: For any value of m such that 2 ≤ m ≤ n – 3, there is continuous representation from Dm E m to Dm1 Em1 . m2 m m2 m Proof: By Lemma 1, we have Dm Em = 2mn n . We , 3mn 2 2 need to show that for the above values of m, when we subtract the smallest element of Dm1 Em1 from the smallest element of Dm Em , the difference is greater than or equal to -1. This difference is equal to m(m 1) m(m 1) m(m 1) m(m 1) n 2n(m 1) 3mn n 2n(m 1) 3mn 2 2 2 2 = 3mn – m (m + 1) + n – 2mn – 2n = mn – m2 – m – n. We will have continuous representation if mn – m2 – m – n ≥ -1, i.e., if mn – m2 – m – n + 1 ≥ 0. If m = 1, then the left side of this inequality is n – 1 – 1 – n + 1 = -1, which is negative. If m = n – 2, then we have (n – 2) n – (n – 2)2 – (n – 2) – n + 1 = n2 – 2n – n2 + 4n – 4 – n + 2 – n + 1 = -1, which is also negative. If m = 2, we have 2n – 4 – 2 – n + 1 = n – 5. This is non-negative if n ≥ 5*. If m = n – 3, we have (n – 3) n – (n – 3)2 – (n – 3) – n + 1 = n2 – 3n – n2 + 6n – 9 – n + 3 – n + 1 = n – 5, which we know is non-negative for n ≥ 5*. So the difference is negative for m = 1 and non-negative for m = 2, we know that the difference equation has a root for some m such that 1 < m ≤ 2; and since the difference is negative for m = n – 2 and non-negative for m = n – 3, the difference equation also has a root for some m such that n – 3 ≤ m < n – 2. Since the difference equation is a quadratic equation in m, we know that it has only two roots, and thus the equation is non-negative for any m such that 2 ≤ m ≤ n – 3. QED. * If n ≤ 4, then n – 3 ≤ 1. If n = 4 and m ≥ 2, then the difference equation is still negative because m ≥ 2 = n – 2. Similarly, if n = 3 and m ≥ 2, then m ≥ 2 = n – 1 > n – 2, so the difference equation is still negative. Therefore, any values of n less than 5 render this difference equation extraneous. Combining the information from both of these lemmas, we have three separate intervals n2 of continuous representation: D1 E1 , (D m E m ) , and Dn1 En1 . Given the above m2 formula for the interval Dm E m , by substitution we have the following intervals: 5n 2 7n ( D E ) 4 n 1 , 1 m m 2 m2 2 2 5n 7n 5n 3n Dn1 En1 1, 2 2 n2 D1 E1 [2n,4n 1] Note that if n = 2, then n – 2 = 0, and n – 1 = 1, so there is only one interval, D1 E1 . If n = 3, then n – 2 = 1 and n – 1 = 2, so the middle interval is rendered extraneous. Now let Fm be the interval whose elements are derived by adding 4n to each element of Dm E m . Then we have the following intervals: 5n 2 n F 8 n 1 , 1 m 2 m2 2 2 5n n 5n 5n 1, 2 2 n2 F1 = [6n, 8n – 1] Fn1 5n 2 5n 5n 2 6n n 2 2 5n 2 6n n 2 n2 1 an 0 1 , which is one Note that 2 2 2 2 2 2 2 2 n 1 less than the smallest element of S0. Note that (D m E m ) represents every number from 2n m 1 5n 2 3n 5n 2 7 n except 4n (which is one of the terms in the sequence) and . However, we 2 2 5n 2 7n n2 can show that Fm . If we subtract the smallest element in this interval, 8n + 1, 2 m2 to 5n 2 7 n 5n 2 23n , we get 1 , which is positive when n ≥ 5. The derivative of this 2 2 10n 23 difference is , which has a critical value of n = 2.3 and is positive when n ≥ 3. 2 Therefore, because the difference is positive and increasing for n = 5, we know that it is positive 5n 2 7 n 5n 2 n for all n ≥ 5. Now if we subtract from the largest element of the interval, 1, 2 2 5n 2 7 n 5 n 2 n we get 8n – 1, which is positive for all n ≥ 5. Since 8n + 1 ≤ ≤ 1 for n ≥ 5, 2 2 n2 5n 2 7n n2 we know that Fm . If n = 2, the interval ( Dm E m ) does not exist, and 2 m2 m2 2 5n 7n 5n 2 7 n = 12 = 4n, which is 3 , which by definition is not in the sequence. If n = 3, 2 2 5n 2 7 n one of the terms of the sequence. If n = 4, then = 26 and F1 = [24, 31], so 2 5n 2 7n F1 and therefore still has a representation. 2 n 1 n 5n 2 n Now notice that Fm represents every number from 6n to a - except 8n and . 2 2 m 0 from 5n 2 n , and we will find a representation 2 for this number later. If n = 4, then 8n = 32 and En–1 = E3 = [31, 34], so 8n En–1 and therefore If n = 2, then 8n = 16 = s0,0. If n = 3, then 8n = 24 = n2 has a representation. If n ≥ 5, we can show that 8n ( Dm E m ) . If we subtract the smallest 2 element of this interval, 4n + 1, from 8n, we get 4n – 1, which is positive for all n ≥ 5. If we 5n 2 7n 5n 2 23n 1 , we get subtract 8n from the largest element of this interval, 1 , which 2 2 we have already shown to be positive for all n ≥ 5. If we add every term in the sequence from 2n to 3n – 1, we get n 1 n(n 1) ( 2 n i ) 2n 2 2 i 0 4n 2 n 2 n 2 2 2 5n n . 2 5n 2 n Then if we add n to this sum, we get . So now we have representations for every 2 n number from 2n to s0,0 – 1 = a - . 2 We now need to show that the elements of S0 cannot be represented as sums of the previous terms of the sequence. For any two distinct elements of S0, the difference is n2 n2 s 0, j2 s 0, j1 (a j 2 ) (a j1 ) j 2 j1 , 2 2 where 0 ≤ j1 < j2 ≤ n – 2 < n. Then by algebra, we have 0 < j2 – j1 ≤ n – 2 – j1 < n, so the difference of any two elements of S0 must be strictly between 0 and n. But there are no such terms in the sequence, so we cannot represent an element of S0 using previous elements of S0, and we must therefore use at least one of the previous elements of the sequence. Recall that the largest element Fn–1, i.e., the largest number that can be represented by adding n and 4n to all but n n2 1 , which is too small to represent any one term in the interval [2n, 3n – 1], is a = a 2 2 element of S0. Therefore, any representation of an element of S0 must use every term from 2n to 5n 2 n 3n – 1. Recall that this sum is , which is too small to represent any element of S0, and if 2 n 1 5n 2 n we add n to this sum, we get , which is still too small. If we add 4n to ( 2n i ) , we get 2 i 0 n2 5n 2 7n 5n 2 6n n 2 2 1 , which is too large to represent any element of a 2 2 2 2 2 2 S0. Therefore, the elements of S0 cannot be represented as sums of previous terms of the sequence, and must therefore be the next terms of the sequence. Now define the set Px S S i , and assume that the sequence begins with Pk. We i x 1 now need to show that the next terms of the sequence are the elements of Sk+1. First, we need to show that every number greater than 2n and less than the smallest term n2 of Sk+1 (which is an k 1 ) can be represented as a sum of distinct term of the sequence. By 2 definition of the sequence, we know that every integer up to the largest element of Sk (which n2 is an k ) can be represented, so we just need to prove that every integer from 2 n2 n n2 n an k 1 an k to an k 1 1 an k 1 can be represented. By definition, the 2 2 2 2 n set Pk 1 represents the number n and every number from 2n to an k , and we will call this set 2 of represented numbers R. We will now attempt to represent other numbers by adding one or more elements of Sk to each element of R. Let Cm be the set whose elements are all of the possible sums of m distinct elements of Sk. If we add m terms of Sk, we get n2 man k m j1 j 2 ... j m for distinct ji [0, n – 2]. The smallest element of Cm is: 2 n2 n 2 m(m 1) k man k m 0 1 2 ...m 1 man m 2 2 2 n 2 m 1 man k m 2 n m 1 man k m , 2 and the largest element of Cm is: n2 man k m (n 2) (n 2) 1 (n 2) 2 ... (n 2) (m 1) 2 m(m 1) n2 man k m m(n 2) 2 2 n 2 m(m 1) man k m 2 2 n 2 m 1 man k m 2 n m 1 man k m . 2 m Since j i 1 i can represent every integer from its minimum value to its maximum value, we know n m 1 n m 1 k that Cm represents every integer from mank m to man m . By adding 2 2 n m 1 n to each element of Cm, we can represent every number from man k m n to 2 n m 1 man k m n , and we will call this interval Am. If we add each element cj Cm to 2 n each element of R, we can represent every number from 2n + cj to an k c j . Since the 2 elements of Cm are consecutive integers, these intervals intersect, so we can combine these n m 1 intervals and find that we have representations for every number from man k m 2n 2 n n m 1 n m 1 n k k to man k m an (m 1)an m , and we’ll call this interval 2 2 2 2 Bm. If add only one element of Sk (i.e., the elements of C1) to each element of R, by the n2 formulae proven above, we have representations for every number from an k to 2 n2 n n2 n n2 an k an k 1 , from an k n an k 1 to an k n 2 2 2 2 2 n n2 n n2 n an k n 1 , and from an k 2n an k n 1 to an k an k 2 2 2 2 2 2an k 1 . However, we are missing representations for an k n2 s (an i sS i j 0 n n and an k n . Note that 2 2 n2 j) 2 i n 2 n2 (n 1) an j 2 j 0 n 2 (n 1)( n 2) (n 1)an i (n 1) 2 2 i (n 1)an . Then we have k 1 p n 2n 2n 1 ... 2n n 1 4n (n 1)an i pPk 1 i 0 n 1 k 1 i 0 i 0 n (2n i ) 4n (n 1)a n i n 2n 2 nk 1 n(n 1) 4n (n 1)a 2 n 1 n2 n n 2n 4n an k a 2 2 n 4 n 2 n 2 n 8n 5 n 2 6 n an k 2 2 2 2 2 3n an k 2 n an k n , 2 2 n p . 2 pPk 1 {n} Now if n ≥ 4, we can add n – 2 terms of Sk, and we have the following intervals of representation: n n 2 1 n n 2 1 k C n 2 (n 2)an k (n 2) , (n 2)an (n 2) 2 2 n2 n 2 (n 2)an k , (n 2)an k 2 2 n2 n (n 2)an k , (n 2)an k 1 2 2 n2 n2 An 2 (n 2)an k n, (n 2)an k n 2 2 n n (n 2)an k 1, (n 2)an k n 1 2 2 and then an k n2 n2 n Bn 2 (n 2)an k 2n, (n 2)an k an k 2 2 2 n [( n 2)an k n 1, (n 1)an k 1] 2 n n We are missing representations for (n 2)an k and (n 2)an k n . We know that 2 2 (n 3)an k C n 3 and is therefore represented by the sequence. Then we have (n 2)an k p and (n 2)an pPk 1 {n} k n n 2 n 2 p. pPk 1 If we add all n – 1 terms of Sk, we get (n – 1) ank. Then if we add this to each element of R, we can represent (n – 1) ank + n and every number from (n – 1) ank + 2n to (n – 1) ank + ank – n 1 n n an k 1 . However we are missing representations for (n 1)an k j as well as 2 2 j 1 n 1 (n 1)an k n j . Note that j 0 n2 n2 n k c p j an k (n 2)an 2 2 pPk 1 {n} cC n 2 j 0 n2 (n 1)an k 1 j j 0 n 1 (n 1)an k j, j 1 and n2 n2 n k j an k n c p (n 2)an 2 2 pPk 1 cC n 2 j 0 n2 (n 1)an k n 1 j j 0 n 1 (n 1)an k n j. j 1 If n ≥ 5, then n – 2 ≥ 3, and we need to show the numbers that can be represented by adding m terms of Sk for 1 < m < n – 2. If we subtract the smallest element of Am from the largest element of Cm, we have n m 1 n m 1 k k man m n m(n m 1) n man m 2 2 mn m 2 m n . We will have a continuous representation from Cm to Am if mn – m2 – m – n ≥ -1, i.e., if mn – m2 – m – n + 1 ≥ 0. If m = 1, then we have mn – m2 – m – n + 1 = n – 1 – 1 – n + 1 = -1 < 0, so the difference equation is negative for m = 1. If m = 2, then we have mn – m2 – m – n + 1 = 2n – 4 – 2 – n + 1 = n – 5, so the difference is non-negative for n ≥ 5. Since the difference is negative for m = 1 and non-negative for m = 2, then the difference equation has a root for some 1 < m ≤ 2. If m = n – 2, then the difference is (n – 2) n – n – (n – 2)2 – (n – 2) + 1 = n2 – 2n – n – n2 + 4n – 4 – n + 2 + 1 = -1 < 0, so the difference is negative for m = n – 2. If m = n – 3, then the difference is (n – 3) n – n – (n – 3)2 – (n – 3) + 1 = n2 – 3n – n – n2 + 6n – 9 – n + 3 + 1 = n – 5, which is nonnegative for n ≥ 5. Since the difference is negative for m = n – 2 and non-negative for m = n – 3, then the difference equation has a root for some n – 3 ≤ m < n – 2. Since mn – m2 – m – n + 1 is a quadratic equation in m, we know that it has no more than two roots, so there are no roots between 2 and n – 3. Therefore, the difference of the largest term of Cm minus the smallest term of Am will be non-negative for all m from 2 to n – 3 inclusive, and therefore Cm and Am intersect for these values of m. Similarly, if we subtract the smallest value of Bm from the largest value of Am, we have n m 1 n m 1 k k n man m 2n m(n m 1) 2n man m 2 2 mn m 2 m n . We will have a continuous representation from Am to Bm if mn – m2 – m – n ≥ -1, i.e., if mn – m2 – m – n + 1 ≥ 0. We have already shown that this is true if 2 ≤ m ≤ n – 3. Therefore, the difference of the largest term of Am minus the smallest term of Bm will be non-negative for all m from 2 to n – 3 inclusive, and therefore Am and Bm intersect for these values of m, and thus we n m 1 n m 1 n k can represent every number from man k m to (m 1)an m 2 2 2 inclusive. Now if n ≥ 3, we must prove that there are no gaps between the intervals of representation for consecutive values of m. If we add m + 1 terms, then the smallest element of nm2 Cm+1 is (m 1)an k (m 1) . If we subtract the smallest element of Cm+1 from the 2 largest element of Bm, the difference is n m 1 n n m 2 k k (m 1)an (m 1) (m 1)an m 2 2 2 n m 1 n nm2 m (m 1) 2 2 2 2 2 mn m m n mn m 2m n m 2 2 2 2mn 2m 4m 2 2 2 mn m 2m 1 . We will have continuous representation over consecutive values of m if this difference is greater than or equal to -1, i.e., if mn – m2 – 2m ≥ 0. We can factor this inequality into m (n – 2 – m) ≥ 0. This is true if 0 ≤ m ≤ n – 2, which by definition is true because there are n – 1 elements in Sk. (If m = n – 1, we cannot add n elements of Sk, so there is no interval of representation for m = n.) Therefore, there are no gaps between the intervals of representation for consecutive values of m, n and thus we have shown that every number from 2n to an k 1 can be represented as a sum of 2 distinct terms of the sequence. Our next step is to show that each element of Sk+1 cannot be represented by the terms of n2 the sequence up to an k . For any two distinct elements of Sk+1, the difference is 2 n2 k 1 n 2 j 2 an k 1 j1 j 2 j1 , where 0 ≤ j1 < j2 ≤ n – 2 < n. But we an 2 2 already proved earlier that the difference j2 – j1 is not represented in the sequence, so we cannot represent any element of Sk+1 using previous elements of Sk+1. Now note that if we subtract the n2 sum of the elements of Pk 1 from an k 1 , the smallest element of Sk+1, the smallest that 2 the difference can be is n 2 n 2n k 1 n 2 k n k an an n (n 1)an 2 2 2 2 2 2 k (n 1)an 2n 1 n[( n 1)an k 1 2] 1 . 5n 2 6n , by substitution we have a ≥ 16. Then if k 2 = 0, we have (n 1)an k 1 1 16 0.5 8 2 . Therefore, both factors n and [( n 1)an k 1 2] are positive, and since both will remain positive for larger values of n and k, we know that the n2 difference an k p will be greater than zero. Thus each element of Sk+1 is too large 2 pPk 1 to represent using only the elements of Pk 1 , and hence any representation of an element of Sk+1 must use at least one element of Sk. We know that n ≥ 2, so n – 1 ≥ 1. Since a Consider the set C n 2 , the set whose elements are the possible sums of all but one term of n2 n n 2 1 k Sk. The largest element of C n 2 is (n 2)an k (n 2) . If we (n 2)an 2 2 subtract this from the smallest element of Sk+1, we get n 2 n2 n2 k 1 n 2 k nan k (n 2)an k an (n 2)an 2 2 2 2 k 2an n 2 . Then we have n 2 n k 1 n 2 k p (2an k n 2) (an k n) an (n 2)an 2 2 pPk 1 2 2n n 2n 2 2 2 2 5n an k 2 2 5n 5n 2 6n 5n As k increases, this difference increases. If k = 0, we have a 2 2 2 2 5n 2 n 2 0 . Therefore, the difference is always greater than zero, so if we subtract the 2 largest element of C n 2 from the smallest element of Sk+1, the difference is too large to be an k represented using just the elements of Pk 1 . If we use a smaller element of C n 2 and/or a larger element of Sk+1, the difference will still be too large. Therefore, any representation of an element of Sk+1 must use every element of Sk+1. We have shown earlier that the sum of all of the elements of Sk is (n – 1) ank. If we subtract this from the jth element of Sk+1, we get n2 k 1 n 2 j (n 1)an k nan k j (n 1)an k an 2 2 n2 (n n 1)an k j 2 n2 an k j. 2 n2 j S k , and by definition of the sequence, this difference cannot be But an k 2 represented as a sum of the elements of Pk 1 . Therefore, the elements of Sk+1 cannot be represented as sums of previous terms of the sequence, and hence must be the next terms of the sequence. Thus we have shown by induction that the sequence follows the formula stated in the theorem. QED. Works Cited Honsberger, Ross. Mathematical Gems III. Washington, D.C.: Mathematical Association of America, 1985. Knapp, Michael. Unpublished proof. Lowe, Doug and Barry Burd. Java All-In-One Desk Reference for Dummies. Hoboken, NJ: Wiley Publishing, 2007. Schissel, Eric. “Characterizations of Three Types of Completeness.” Fibonacci Quarterly 27 (1989), 409-419.