We call a positive integer N square-partitionable if it can be partitioned into squares of two or more distinct positive integers, and if the sum of the reciprocals of these integers is 1. For example, 4 9 is square-partitionable because 4 9 = 2 2 + 3 2 + 6 2 and 2 1 + 3 1 + 6 1 = 1 . What is the next smallest square-partitionable integer?
Note : This problem is intended to be solved with programming.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
So in general if N = a 1 2 + ⋯ + a n 2 , 1 = a 1 1 + ⋯ + a n 1 , then 4 N + 4 = 2 2 + 2 2 ( a 1 2 + ⋯ + a n 2 ) , 1 = 2 1 + 2 1 ( a 1 1 + ⋯ + a n 1 ) ; 4 N + 4 = 2 2 + ( 2 a 1 ) 2 + ⋯ + ( 2 a n ) 2 , 1 = 2 1 + 2 a 1 1 + ⋯ + 2 a n 1 .
Therefore you can start with the observation N = 4 9 and repeatedly apply N ↦ 4 N + 4 to generate an infinite list of solutions; or, N = 1 2 1 5 1 ⋅ 4 n − 1 6 n = 1 , 2 , … all satisfy the condition. The first few terms are N = 4 9 , 2 0 0 , 8 0 4 , 3 2 2 0 , 1 2 8 8 4
Log in to reply
(I'm just making this implicit statement explicit for everyone else.)
This approach gives us an infinite family of solutions. However, it doesn't give us all possible solutions.
See Arjen's solution for other examples like 1 = 3 1 + 4 1 + 5 1 + 6 1 + 2 0 1 . It just happens that the next smallest value could be derived in this manner.
I was curious about closed form expression Arjen wrote, so I derived it for myself. I will post it here so that everyone who maybe wonders how it came up now now knows.
First, notice that this is non-homogeneous recurrence relation. That means that we will first have to solve homogeneous, then guess the form of particular solution and solve it and our final solution will be the sum of those two.
Corresponding homogeneous recurrence relation is a n + 1 = 4 a n , and solution is pretty straightforward a n = α ⋅ 4 n where α is some constant whose value we will determine later.
For non-homogeneous we will guess the solution in the form of A which is also some constant. Thus final solution is the form of a n = α ⋅ 4 n + A . If we let a 1 = 4 9 and a 2 = 2 0 0 , and plug those values in our solution form we get the following system of equations: 4 9 = α ⋅ 4 1 + A 2 0 0 = α ⋅ 4 2 + A Subtracting first from the second we get α = 1 2 1 5 1 . Now, plugging that back in the one of two equations yields A = − 3 4 = − 1 2 1 6 . Now we know all the constants and have the complete closed form expressions for our recurrence: a n = 1 2 1 5 1 ⋅ 4 n − 1 6
I may not be familiar with the definition of square-partitionable, but the problem should have said we are looking for positive integers. If we take the text of the problem strictly, 51 is a good solution, with the three distinct integers being -5, 1, 5. (haven't checked for 50, I must admit)
Log in to reply
Good point. I will edit the problem to reflect this. (Instead of squares of distinct integers, it must be distinct squares of integers...)
However, it is not known for sure if this is the next smallest square-partitionable integer, since there could be a smaller one that does not involve a 2, but fortunately, this is not the case.
Can you explain your proof a bit more? I am not able to follow especially this line.
Log in to reply
What D C showed is that given a solution to the problem with n terms, you can easily generate another solution with n + 1 terms. This generates an infinite "family" of solutions. Starting with the given solution of N = 4 9 and three terms, he generated the solution with N = 2 0 0 and four terms.
However, being able to generate infinitely many solutions is not the same as generating all solutions.
It might therefore be the case, that there is a solution between N = 4 9 and N = 2 0 0 , which however is not part of this family. In that case, D C's answer of 200 would have been incorrect.
Log in to reply
Yes, but how does D C know that there is no solution between 49 and 200?
Log in to reply
@Agnishom Chattopadhyay – He didn't until he saw that Brilliant said the answer was correct. That is precisely the point of his remark that "it is not known for sure if this is the next smallest square-partitionable integer."
From reading the question I thought the square-partitionable had to be a square itself like 49 in which case the answer is 2704 the sum of the following squares 2,3,9,33,39
Log in to reply
But the sum of reciprocals in that case is not equal to 1.
wait you didn't say that the integers can't be repeated ! 1/4+1/4+1/3+1/6=1 should be the next number that is 16+16+9+36=77 !
Log in to reply
Yes, he did:
... into squares of two or more distinct positive integers ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
We see that the example solution of 49 is the smallest; the second-smallest is 2 0 0 = 2 2 + 4 2 + 6 2 + 1 2 2 , and indeed 2 1 + 4 1 + 6 1 + 1 2 1 = 1 2 6 + 3 + 2 + 1 = 1 .
Explanation: The work is done by the recursive function
split_squares
. At any point in the calculation, we have
N
=
t
0
2
+
t
1
2
+
⋯
+
t
c
−
1
2
+
M
;
t
0
1
+
t
1
1
+
⋯
+
t
c
−
1
1
=
d
n
.
The process ends
successfully
if
M
=
0
and
n
=
d
. It
fails
if
M
=
0
but
n
<
d
; or if
n
=
d
but
M
>
0
; or if
M
<
0
or
n
>
d
.
If M > 0 and n < d , we add a term t c . It must be greater than the preceding term; we generate the terms in increasing order. Then the new values for recursion are M ′ = M − t c 2 ; d ′ n ′ = d n + t c 1 = d t c n t c + d . To ensure that M ′ ≥ 0 we limit t c 2 ≤ M . Also, to ensure that the fraction does not exceed 1, we require n t c + d ≤ d t c ; this translates to a minimum value, t c ≥ ⌈ d / ( d − n ) ⌉ .
Note: this program is not stable for much larger values of N . This can be fixed, at least in part, by dividing the new numerator and denominator by their greatest common divisor before recursion.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
Log in to reply
looks very efficient, my python script took a few seconds just to find 200 on a raspberri pi :-)
Nice work! Arjen. This Python recursive version uses LCMs to solve Note: for what it's worth, a couple of numbers above 1000 (and below) 1300 have 2 solutions...1090 and 1213
Brilliant, Can you post below solution please as a separate solution to this prob..tx
Sir, I am truly amazed by this can you please teach me the programming. Your Sincerely Abhay Sharma
Its easy. Just need to keep solving problems....start easy and work your way to more difficult ones.
[EDIT: This comment refers to a previous wording of the problem.]
The wording should include the requirement that the integers used in the sum be positive :
"We call a positive integer N square-partitionable if it can be partitioned into squares of at least 2 distinct positive integers, and if the sum of the reciprocals of these positive integers is 1."
That is how I (and most everyone else) interpreted the question. But as currently worded, you can use reciprocals of negative integers, and thus get solutions with N less than 200.
1 1 + − 2 1 + 3 1 + 6 1 = 1 leads to N = 1 2 + ( − 2 ) 2 + 3 2 + 6 2 = 5 0
1 1 + − 3 1 + 4 1 + 1 2 1 = 1 leads to N = 1 2 + ( − 3 ) 2 + 4 2 + 1 2 2 = 1 7 0
2 1 + 3 1 + 4 1 + − 1 2 1 = 1 leads to N = 2 2 + 3 2 + 4 2 + ( − 1 2 ) 2 = 1 7 3
The integers do not have to be negative as the square of the 2 integers (-ve or +ve) are going to be the same.
Log in to reply
The squares are positive, but not the reciprocals.
Good eye. We've fixed the wording of the problem so that the intended solution of 200 is correct.
Yes, badly worded question!! Need to brush up on your English.
You try to partition the fraction with the smallest possible denominator into two other fractions with smallest possible denominators. Since 2 cannot be partitioned (already partitioned into 1/3 and 1/6), you partition the 1/3 into two other fractions, 1/4 and 1/3 - 1/4 = 1/12. Therefore, you add up the denominators squared: 2^2 + 4^2 + 6^2 + 12^2 = 4 + 16 + 36 + 144 = 200.
My Python code:
def rekurs(n, sand, sum, i):
if n == 0:
return sum == sand
while i * i <= n:
if rekurs(n - i * i, sand * i, sum * i + sand, i + 1):
return True
i += 1
return False
def check(n):
return rekurs(n, 1, 0, 2)
i = 50
while not check(i):
i += 1
print(i)
C#:
void Main()
{
for (int n = 0; n < 1100; n++) {
var partitions = PartitionIntoAscendingSquares(1,n)
.Where( part => part.Count() > 1) // at least 2 squares
.Where( part => { // reciprocals add to 1
var prod = part.Aggregate(1, (p,x) => p*x); // denominator
var sums = part.Aggregate(0, (s,x) => (prod/x) + s); // numerators
return sums == prod;
});
if (partitions.Count() > 0)
foreach (var part in partitions)
Console.WriteLine($"{n}: {String.Join(",", part.OrderBy(x=>x))}");
}
}
IEnumerable<IEnumerable<int>> PartitionIntoAscendingSquares(int from, int n) {
if (n == 0)
yield return new int [] {} ;
else
for (int i = from; i * i <= n; i++)
foreach (var part in PartitionIntoAscendingSquares(i + 1, n - i * i))
yield return part.Concat(new int[] {i});
}
49: 2,3,6
200: 2,4,6,12
338: 2,3,10,15
418: 2,3,9,18
445: 2,4,5,20
486: 3,4,5,6,20
489: 2,4,10,12,15
530: 3,4,6,10,12,15
569: 2,4,9,12,18
609: 2,5,6,12,20
610: 3,4,6,9,12,18
653: 2,3,8,24
770: 2,6,9,10,15,18
775: 3,4,5,10,15,20
804: 2,4,8,12,24
845: 3,4,6,8,12,24
855: 3,4,5,9,18,20
898: 2,5,10,12,15,20
899: 3,4,9,10,12,15,18
939: 3,5,6,10,12,15,20
978: 2,5,9,12,18,20
1005: 2,6,8,10,15,24
1019: 3,5,6,9,12,18,20
1049: 2,4,7,14,28
1065: 2,5,6,10,30
1085: 2,6,8,9,18,24
1090: 3,4,5,8,20,24
1090: 3,4,6,7,14,28
200 is the second smallest integer. 1090 is the first with 2 distinct solutions.
Not a proof but I did get the answer by constructing a few such numbers backward:
In the example, the factors of 6 are 1,2,3,6 and the subset 1+2+3=6. 6/1=6, 6/2=3, 6/3=2 and 6^2+3^2+2^2=49
The key is to find a number whose factors contain a subset that sums to the number.
The next such number is 12. Factors are 1,2,3,4,6,12 (2,4,6 will give the example) and the subset is 1,2,3,6. 12^2+6^2+4^2+2^2= 200
The next number is 18 which gives 418 and 20 gives 445
I stopped there and got lucky. As Arjen's table shows, 30 gives a somewhat small 338 (by avoiding the factor 1)
if look at the 2nd part
2 1 + 3 1 + 6 1 = 1
which is 3 + 2 + 1 = 6
we can see only integers for whom a subset of factors can add to themselves can satisfy this criteria like in this case 1, 2, 3 factors of 6 add upto 6
the next integer after 6, this is possible for is 12. 1,2,3,6 and 2,4,6 add upto 12.
2,4,6 is same as first case.
for 1,2,3,6 we have,
1 2 1 + 1 2 2 + 1 2 3 + 1 2 6
= 1 2 1 + 6 1 + 4 1 + 2 1
which gives
1 2 2 + 6 2 + 4 2 + 2 2 = 2 0 0
Problem Loading...
Note Loading...
Set Loading...
You can approach a solution easily without code by multiplying the original sum by 1 / 2 to get:
1 / 2 = 1 / 4 + 1 / 6 + 1 / 1 2
Then we can add 1 / 2 to our new sum to get:
1 = 1 / 2 + 1 / 4 + 1 / 6 + 1 / 1 2
Finally, we add the squares of the denominators to get:
2 2 + 4 2 + 6 2 + 1 2 2 = 2 0 0
Notice it is easy to deduce that 200 is the next smallest square-partitionable integer involving a 2, since the remaining terms of the reciprocal sum must add to 1 / 2 , and by dividing the reciprocal sum of the smallest solution by 2, we end up with the best reciprocal sum to add to 1 / 2 . However, it is not known for sure if this is the next smallest square-partitionable integer, since there could be a smaller one that does not involve a 2, but fortunately, this is not the case.
Thus the answer must be 2 0 0 .