Prove that

**Problem 7.** Let be a nonconstant polynomial with real coefficients. For every positive integer let

Prove that there are only finitely many numbers such that all roots of are real.

**Problem 8.** Define the sequence of matrices by the following recurrence

where is the identity matrix.

Prove that has distinct integer eigenvalues with multiplicities , respectively.

**Problem 9.** Define the sequence of continuously differentiable functions by the following recurrence

Show that exists for every and determine the limit function.

**Problem 10.** Let be an equilateral triangle in the plane. Prove that for every there exists an with the following property: If is a positive integer and are non-overlapping triangles inside such that each of them is homothetic to with a negative ratio and

then

]]>

**Problem 2.** Let be a differentiable function and suppose that there exists a constant such that

for all . Prove that

holds for all .

**Problem 3.** For any positive integer denote by the product of positive divisors of . For every positive integer define the sequence

Determine whether for every set there exists a positive integer such that the following condition is satisfied:

*For every with the number is a perfect square if and only if .*

**Problem 4.** There are people in a city and each of them has exactly friends (friendship is mutual). Prove that it is possible to select a group of people such that at least persons in have exactly two friends in .

**Problem 5.** Let and be positive integers with and let

be a polynomial with complex coefficients such that

Prove that and have at most common roots.

]]>

- the circumcenter O of each of the triangles is the origin
- the orthocenter H (the intersection of the heights) is the point of coordinates (0,5)
- the perimeter is lower than a certain bound

I will not give detailed advice or codes. You can already find a program online for this problem (I won’t tell you where) and it can serve to verify the final code, before going for the final result. Anyway, following the hints below may help you get to a solution.

The initial idea has to do with a geometric relation linking the points A, B, C, O and H. Anyone who did some problems with vectors and triangles should have come across the needed relation at some time. If not, just search for important lines in triangles, especially the line passing through O and H (and another important point).

Once you find this vectorial relation, it is possible to translate it in coordinates. The fact that points A, B, C are on a circle centered in O shows that their coordinates satisfy an equation of the form , where is a positive integer, not necessarily a square… It is possible to enumerate all solutions to the following equation for fixed , simply by looping over and . This helps you find all lattice points on the circle of radius .

Once these lattice points are found one needs to check the orthocenter condition. The relations are pretty simple and in the end we have two conditions to check for the sum of the x and y coordinates. The testing procedure is a triple loop. We initially have a list of points on a circle, from the previous step. We loop over them such that we dont count triangles twice: i from 1 to m, j from i+1 to m, k from j+1 to m, etc. Once a suitable solution is found, we compute the perimeter using the classical distance formula between two points given in coordinates. Once the perimeter is computed we add it to the total.

Since the triple loop has cubic complexity, one could turn it in a double loop. Loop over pairs and construct the third point using the orthocenter condition. Then just check if the point is also on the circle. I didn’t manage to make this double loop without overcounting things, so I use it as a test: use double loops to check every family of points on a given circle. If you find something then use a triple loop to count it properly. It turns out that cases where the triple loop is needed are quite rare.

So now you have the ingredients to check if on a circle of given radius there are triangles with the desired properties. Now we just iterate over the square of the radius. The problem is to find the proper upper bound for this radius in order to get all the triangles with perimeter below the bound. It turns out that a simple observation can get you close to a near optimal bound. Since in the end the radii get really large and the size of the triangles gets really large, the segment OH becomes small, being of fixed length 5. When OH is very small, the triangle is almost equilateral. Just use the upper bound for the radius for an equilateral triangle of perimeter equal to the upper bound of 100000 given in the problem.

Using these ideas you can build a bruteforce algorithm. Plotting the values of the radii which give valid triangles will help you find that you only need to loop over a small part of the radii values. Factoring these values will help you reduce even more the search space. I managed to solve the problem in about 5 hours in Pari GP. This means things could be improved. However, having an algorithm which can give the result in “reasonable” time is fine by me.

I hope this will help you get towards the result.

]]>

]]>

for all

*Solution:* Note that we obviously have

and using the hypothesis we obtain that

for every . Now we have two options. Suppose the image of is unbounded. Then, since if we fix it would follow that has arbitrarily large divisor, which is not possible unless . This is one solution, as it can easily be checked.

The other alternative is that is bounded. If this is true, then there is a value of which is repeated for an infinite increasing sequence : . It follows that

for every and for defined as above. Since the fraction

is an integer and it converges to as it follows that for large enough we have . This implies that , and this is independent of . Therefore is constant. From the previous relation we have so the only possible constant is .

]]>

**Problem 2.** Consider an acute-angled triangle with and let be its circumscribed circle. Let and be the tangents to the circle at points and , respectively, and let be their intersection. The straight line passing through the point and parallel to intersects in point . The straight line passing through the point and parallel to intersects in point . The circumcircle of the triangle intersects in , where is located between and . The circumcircle of the triangle intersects the line (or its extension) in , where is located between and .

Prove that , , and are concurrent.

**Problem 3.** Let denote the set of positive integers. Find all functions such that

for all

**Problem 4.** On a circular table sit students. First, each student has just one candy. At each step, each student chooses one of the following actions:

- (A) Gives a candy to the student sitting on his left or to the student sitting on his right.
- (B) Separates all its candies in two, possibly empty, sets and gives one set to the student sitting on his left and the other to the student sitting on his right.

At each step, students perform the actions they have chosen at the same time. A distribution of candy is called legitimate if it can occur after a finite number of steps. Find the number of legitimate distributions.

(Two distributions are different if there is a student who has a different number of candy in each of these distributions.)

Source: AoPS

]]>

*Mathematical Mind-Benders, Peter Winkler*

**Hint: **Work with remainders modulo 9.

]]>

Recently, I decided to try and see if I can do some more of these problems. I cannot say that I’ve acquired some new techniques between 2012-2016 concerning the mathematics involved in these problems. My research topics are usually quite different and my day to day programming routines are more about constructing new stuff which works fast enough than optimizing actual code. Nevertheless, I have some experience coding in Matlab, and I realized that nested loops are to be avoided. Vectorizing the code can speed up things 100 fold.

So the point of Project Euler tasks is making things go well for large numbers. Normally all problems are tested and should run within a minute on a regular machine. This brings us to choosing the right algorithms, the right simplifications and finding the complexity of the algorithms involved.

For example if you need to compute a certain sum what is the best way to proceed? Computing each in turn and summing them up in a loop gives us an algorithm. This means that computation time is roughly proportional to (this depends also on , but let’s suppose is something which we can compute in time, that is, instantly). Therefore, if is of order , this can be done on a regular machine. However, if , it may take, literally, ages for the algorithm to finish. For an algorithm of complexity , which scales with the square root of , should work. However let’s say you have in mind. Then either we find some algorithm with large enough or, even better, find a algorithm, which scales like . Roughly, if the algorithm works for , it should only take times more time to reach . Best of all, if you can find a direct formula for the sum, then you have an “instant” algorithm (whether this is instant or not depends on the formula you got…).

Maybe this could become more clear using some examples.

1. . The basic summation is time, but using the formula gives an algorithm. Basically, you can compute this sum for any you want by doing a couple of elementary operations.

2. Let’s complicate things a bit. What if is : the sum of all the divisors of ? First let’s note that computing alone is not immediately computable. One can imagine a basic algorithm, testing all integers if and summing them. If we know the factorization of we have a formula for in terms of prime factors and their powers. Prime factorization’s complexity is provided we have already made a sieve of primes (that’s other thing to think about). So we reach a complexity for . This is not enough if we want to sum things up to , for example. It turns out there’s a simple idea for a less complex algorithm.

We want to compute

Now what if we invert the sums? How do we do this? The summation indices satisfy . Thus, if we want to sum over instead of , then would be a multiple of all the time. So we find the alternative sum

where the last equality is valid since the number of multiples of less than is exactly . This already gives an complexity. Better than before, no factorizations involved, quite nice.

It turns out we can do even better. Looking at terms of the form we see that they take the same value multiple times. For example implies

Thus, summing on this interval we have

where the last sum has an explicit value since we sum consecutive terms of an arithmetic progression. Now we can switch to a summation over instead of . Note that we only need to go to high enough such that between and there is at least one integer. This is equivalent to so is . For larger than this value, we cannot guarantee the existence of an integer in our interval, so we’ll just compute the sums up to this and then sum the remaining terms which are again of order . This gives us a final algorithm.

Now, it is clear that if we need to compute our sum of sums of divisors up to , for example, only an algorithm like the last one can lead us to the result in reasonable time. Now you can solve Problem 401 in no time (replacing the sum of divisors with sum of squares doesn’t make much difference here, or does it?)

I hope this will motivate others to gain or regain interest in Project Euler problems. I solved over 120 problems in the last two months by learning to adapt algorithms and doing the necessary research when it is needed. Almost always, after solving a problem, you’ll find someone in the solution thread which has a better solution than yours. Look it up and continue improving your skills.

Project Euler problems don’t require only maths… Sometime more complex computer science stuff is needed. I learned the basics of dynamic programming and recursion solving some of the problems. I learned using lists, queues, combinatorial stuff, probabilities (still learning that though; lots of probability related stuff among PE problems). Not to mention that I learned to work quite well in some different languages, like Pari GP or Julia. It also forced me to compile and use some Java or Python codes.

It is a globally enriching quest: keep up with your maths, learn to do research online, improve programming skills, find new algorithms, choose right programming language to solve your problem efficiently, etc. It’s a hobby worth having.

]]>

To save you some time, here’s a picture of the case k=1 which I ignored and spent quite a lot of time debugging… Plus, it only affects the last three digits or so after the decimal point…

Here’s a Matlab code which can construct the pictures above and can compute the result for low cases. To solve the problem, you should compute explicitly all these areas.

function problem285(k) N = 100000; a = rand(1,N); b = rand(1,N); ind = find(abs(sqrt((k*a+1).^2+(k*b+1).^2)-k)<0.5); plot(a(ind),b(ind),'.'); axis equal M = k; pl = 1; for k=1:M if mod(k,100)==0 k end r1 = (k+0.5)/k; r2 = (k-0.5)/k; f1 = @(x) (x<=(-1/k+r1)).*(x>=(-1/k-r1)).*(sqrt(r1^2-(x+1/k).^2)-1/k).*(x>=0).*(x<=1); f1 = @(x) f1(x).*(f1(x)>=0); f2 = @(x) (x<=(-1/k+r2)).*(x>=(-1/k-r2)).*(sqrt(r2^2-(x+1/k).^2)-1/k).*(x>=0).*(x<=1); f2 = @(x) f2(x).*(f2(x)>=0); if k == pl thetas = linspace(0,pi/2,200); hold on plot(-1/k+r1*cos(thetas),-1/k+r1*sin(thetas),'r','LineWidth',2); plot(-1/k+r2*cos(thetas),-1/k+r2*sin(thetas),'r','LineWidth',2); plot([0 1 1 0 0],[0 0 1 1 0],'k','LineWidth',3); hold off axis off end A(k) = integral(@(x) f1(x)-f2(x),0,1); end xs = xlim; ys = ylim; w = 0.01; axis([xs(1)-w xs(2)+w ys(1)-w ys(2)+w]); sum((1:k).*A)

]]>

Now what happens if we add a little bit of wind? Here’s the perturbation obtained when adding a 10m/s uniform wind speed vs the initial configuration. Something like this would be a lot more challenging

]]>