Thursday, April 16, 2026

Primitive Pythagorean triples with the help of trigonometry

 Not a puzzle, just a quick note.

Primitive pythagorean triples are of the form $m^2 - n^2, 2mn, m^2 + n^2$ with $m,n$ relatively prime and of opposite parities.

We will use trigonometry to help derive this.

Let $a,b,c$ with $a^2 + b^2 = c^2$ be a primitive pythagorean triplet. This means $\gcd(a,b,c) = 1$. Note that this also implies that $a,b,c$ are pairwise coprime. Thus exactly one of $a,b,c$ is even. It cannot be $c$ as that would imply $4$ divides $a^2 + b^2$ for $a,b$ odd (which is not possible). 

Thus assume $b$ is even. 

We can now prove that 

$\textbf{Proposition:}$ The highest power of $2$ that divides $b$ is different from the highest power of $2$ that divides $a+c$. 

$\textbf{Proof:}$ Since $a,c$ are odd and relatively prime, we must have that $\gcd(a+c, c-a) = 2$. Thus $a+c = 2u$ and $c-a = 2v$ for some odd $u,v$. Now if $b = 2w$ for some odd $w$ (if we assume that the highest power of $2$ that divides $b$ is same as $a+c$), then $b^2 = (c+a)(c-a) \implies w^2 = uv$. Since $w^2 = 1 \mod 4$, this implies $u = v$ mod $4$, and thus $a = u - v = 0 \mod 4$, not possible.

Now consider the triangle $$B = (0,0), C = (a, 0), A = (a,b)$$

Draw the anglular bisector $BD$ of angle $B$ such that $D$ lies on $AC$. By the angular bisector theorem, $CD/DA = a/c$ and hence $CD = \frac{ab}{a+c}$. Thus we have that

$$\tan \left(\frac{B}{2}\right) = \frac{CD}{BC} = \frac{b}{a+c} = \frac{n}{m}$$

For some $n, m$ relatively prime.  Since the highest power of $2$ that divides $b$ is different from that of $a+c$, $n,m$ are of opposite parities.

Now using $\tan 2x = \frac{2 \tan x}{1 - \tan^2 x}$ we get

$$\frac{b}{a} = \tan B = \frac{2 n/m}{1 - (n/m)^2} = \frac{2nm}{m^2 - n^2}$$

We can show that $2mn$ and $m^2 -n^2$ are relatively prime if $m,n$ are relatively prime and of opposite parities: if a prime $p > 2$ divides the numerator, it has to divide one of $m,n$ and cannot divide the denominator also. The denominator is also odd, so their $\gcd$ cannot be $2$.

Thus $$b = 2mn, a = m^2 - n^2, c = m^2 + n^2$$

Sunday, April 5, 2026

Limit of sum of first $n^{th}$ powers.

 Came across this problem recently, posed as apparently an IIT JEE exam question (though I haven't been able to find the exact year). This is a horrible question for the exam (which is usually multiple choice with negative marking) because it rewards bad students and punishes the good students. And as expected, the IIT JEE coaching class solution I found for this was utterly wrong. A sad state of affairs.

Here is the gist of the question (the actual question was a bit different, but this is the crux of the question).

Find $$\lim_{n \to \infty} \dfrac{1^n + 2^n + \dots + n^n}{n^n}$$

The wrong solution goes as follow


$$\sum_{j=1}^{n} \left(\dfrac{j}{n}\right)^n = \sum_{k=0}^{n-1} \left(\dfrac{n-k}{n}\right)^n$$

$$ = \sum_{k=0}^{n-1} \left(1 - \dfrac{k}{n}\right)^n = \sum_{k=0}^{n-1} e^{-k} = \dfrac{e}{1-e}$$

The step going to $e^{-k}$ is wrong, without some additional justification. In fact, it can be justified using theorems (like monotone/dominated convergence theorems) which is not in the syllabus of IIT JEE. A good student who does not know those theorems will likely be stuck, while a bad student will happily get the right answer by using pretty faulty reasoning.

Below is an attempt to prove that the limit is $\dfrac{e}{e-1}$ using "elementary" means.


The steps are similar till


$$  \dfrac{1^n + 2^n + \dots + n^n}{n^n} = \sum_{k=0}^{n-1} \left(1 - \dfrac{k}{n}\right)^n$$

At this point we try to give upper and lower bounds which ultimately give us the limit we seek,

We use $e^{x} \ge 1 + x$ multiple times. 

Setting $x = \frac{-k}{n}$ gives us $e^{-k/n} \ge (1 - k/n)$ and thus $$ \left(1 - \dfrac{k}{n}\right)^n \le e^{-k}$$

Setting $x = \frac{t}{1-t}$ gives us $e^{t/(1-t)} \ge \frac{1}{1-t}$, and so $e^{t} \ge (1-t)^{t-1}$ and thus $(1-t)^{1-t} \ge e^{-t}$

Setting $t = \frac{k}{n}$ and rearranging gives us


$$\left(1 - \dfrac{k}{n}\right)^n \ge \left(1 - \dfrac{k}{n}\right)^k e^{-k}$$

By Bernouli's inequality $\left(1 - \dfrac{k}{n}\right)^k \ge \left(1 - \dfrac{k^2}{n}\right)$ and so we have the bounds

$$e^{-k} \ge \left(1 - \dfrac{k}{n}\right)^n \ge \left(1 - \dfrac{k^2}{n}\right) e^{-k}$$

Taking the sum from $k = 0$ to $n-1$, and noticing that $\sum k^2 e^{-k}$ is $O(1)$ and hence $\frac{1}{n}\sum k^2e^{-k} \to 0$ as $n \to \infty$ gives us the result.

Tuesday, March 24, 2026

Powers of 2 as integer parts of irrational multiples

Suppose $\alpha$ is an irrational number in $(0, 2)$.

Prove that there exist infinitely many positive integers $n$ such that the integer part of $n \alpha$  (i,e $[n \alpha]$) is a power of $2$.


Solution.

.

.

.

.

.

Since $\alpha$ is irrational, so is $\beta = \frac{1}{\alpha}$. The binary expansion of $\beta$ contains the binary digit $1$ infinitely often (otherwise it would be rational).

This means, for infinitely many $m$ we have the following

$$2^{m} \beta = N_m + f_m$$

with $N_m$ is the integer part of $2^m\beta$ and $f_m$ is the fractional part, with $\dfrac{1}{2} < f_m < 1$. We choose $m$ so that $2^m \beta$ has $1$ just after the "binary" point.

Now since $\alpha < 2$, $\beta > \frac{1}{2}$ and thus


$$2^{m}\beta + \beta > N_m + f_m + \frac{1}{2} > N_m + 1$$

And thus we have


$$2^{m} \beta < N_m + 1 < 2^m \beta + \beta$$

Dividing by $\beta$ gives

$$2^{m} < (N_m+1) \alpha < 2^m  + 1$$

i.e 

$$ [(N_m+1) \alpha] = 2^m$$

Since we had infintely many choice for $m$, we are done.

Sunday, February 22, 2026

Replicating Amoebas

 This is a puzzle from Peter Winkler who himself got it from some field medalist apparently.


You have an amoeba at $(0,0)$. An amoeba can replicate by splitting itself,  and placing them one to the right and one above.

So if an amoeba is at $(x,y)$ after the replication of that, there will be no amoeba at $(x,y)$, one at $(x+1, y)$ and one at $(x, y+1)$.

This replication can only happen if the two target spots are empty. Otherwise the amoeba will not replicate. 

For eg starting with $(0,0)$ consider the following.

A split, now we have $(1,0)$ and $(0,1)$. 

The $(0,1)$ splits, now we have $(1,0), (1,1), (0,2)$.

Now if the $(1,0)$ wants to split, it cannot, because one of the targets $(1,1)$ is occupied.

Ok now for the puzzle.

You start with one amoeba at $(0,0)$. 

How many replications do we need to clear the square (including the inside of it) $(0,0), (2,0), (2,2), (0,2)$ of amoebas?


Solution.

.

.

.

.

.


The answer is, it is impossible to clear that grid!


We come up with an invariant. Give weight $1$ to the initial amoeba. If an amoeba of weight $w$ splits, give weights $\frac{w}{2}$ to each of its clones. Thus the total weight of amoebas is preserved.

Now the weights are non-positive powers of $2$ and given the location of the amoeba, you can actually determine its weight.

The weights look something like this ($(0,0)$ is bottom left of matrix)

$$\begin{matrix} \vdots & \vdots & \vdots & \vdots \\ \frac{1}{8} & \frac{1}{16} & \frac{1}{32} & \frac{1}{64} &\dots \\ \frac{1}{4} & \frac{1}{8} & \frac{1}{16} & \frac{1}{32}  & \dots \\ \frac{1}{2} & \frac{1}{4} & \frac{1}{8} & \frac{1}{16} & \dots \\ 1 & \frac{1}{2} & \frac{1}{4} & \frac{1}{8} & \dots \end{matrix}$$


Now the sum of all the weights in the grid of our interest  is $$ 1 + 2 \times \frac{1}{2} + 3 \times \frac{1}{4} + 2 \times \frac{1}{8}  + \frac{1}{16} = 3 \frac{1}{16}$$


The sum of weights of all the possible spaces is $S + \frac{S}{2} + \frac{S}{4} + \dots = S^2 $ where $S$ is the sum of the weights of the bottom row. 

It is easily seen that $S=2$, so the whole infinite grid sum is $4$.

Thus the sum of weights outside our grid of interest is no more than $4 - 3\frac{1}{16} < 1$.

Thus it is impossible to clear that grid, starting with a single amoeba at $(0,0)$, of initial weight $1$: there has to be some amoeba inside the grid to preserve the total weight of $1$.

Friday, February 20, 2026

A generalization of sum of squares

 Let $A_1, A_2 \dots A_n$ be $n$ points in the 2D plane, with centroid $M$.


Show that for any point $P$ in the plane


$$ \sum_{i = 1}^{n} PA_{i}^2 = n PM^2  + \sum_{i=1}^{n} MA_{i}^2$$


Bonus: Given a magic fairy that tells you the sum of squares of distances of any point $P$ to $A_1, A_2, \dots, A_m$ where you don't know $m$ or the $A_i$, show that you can find $m$ in a finite number of queries to the magic fairy.


Solution

.

.

.

.

.


Surprisingly this has an easy proof using complex numbers!


Let $a_1, a_2, \dots, a_n$ be complex numbers that sum to $0$,


Then we have that for any complex number $z$,


$$\sum_{i=1}^{n} |z-a_i|^2 = \sum_{i=1}^{n} (z-a)\overline{(z-a)} = $$

$$ \sum_{i=1}^{n} (z\overline{z} - z\overline{a_i} -\overline{z}a_i + a_i\overline{a_i}) = $$

$$ n z \overline{z} + \sum_{i=1}^{n} a_i\overline{a_i}  = n |z|^2 + \sum_{i=1}^{n} |a_i|^2$$


This gives us the identity we seek. The centroid $M$ corresponds to $0$, the sum of $a_i$.

The bonus puzzle solution follows along the lines of the previous guessing puzzle, and I will leave it to you.


Thursday, February 19, 2026

Guessing the area from sum of squares of distances

 There is an equilateral triangle $ABC$ in the 2D plane. You don't know where it is, but have access to a magical fairy that, given a point $P$ in the same plane, will give you the value of $$f(P) = |PA|^2 + |PB|^2 + |PC|^2$$ i.e. the sum of squares of distances from $P$ to $A,B,C$ (henceforth we will drop the absolute sign)


i) Can you find out the area of triangle $ABC$ using only a finite number of queries to the fairy?

ii) Can you find the minimum number of queries you need to (and are sufficient) to guess the area?

iii) Can you find the locations of the three vertices?


Solution

.

.

.

.

.

Part i)

In a previous post we showed the following:

For any triangle $ABC$ with centroid $M$ and any point $P$ in the same plane


$$ PA^2 + PB^2 + PC^2 = 3 PM^2 + AM^2 + BM^2 + CM^2$$

(Can easily be proven using complex numbers too, if required).

i.e we have $$f(P) = 3 PM^2 + S$$

where $S$ is a constant, independent of $P$ (and is actually a constant times the area of $ABC$, for equilateral $ABC$).

Now pick points $X, Y$ (say $(0,0), (1,0)$) and query the fairy for $X$ and $Y$.

We have that $$f(X) - f(Y) = 3(XM^2 - YM^2)$$

i.e $M$ lies on the locus of points $Q$ such that $$QX^2 - QY^2 = k$$

$k$ is a constant.

By simple co-ordinate geometry, this actually can easily be seen to be a line perpendicular to $XY$ (extended, if needed).

Thus using two points, we narrow down $M$, the centroid of $ABC$ to a straight line. With another point $Z$ (say $(0, 1)$), we get another line, and take the intersection of the two lines.

Once we have the location of $M$, we can compute $XM^2$ directly, and then use the already obtained $f(X)$ to compute the area of the equilateral triangle $ABC$, using

$$ AM^2 + BM^2 + CM^2 = f(X) - 3 XM^2$$


Thus three queries are sufficient. 

Part ii)

Three queries are also necessary.

Suppose two were enough, (say X and Y), then as before $M$ lies on a line perpendicular to $XY$. Now if $M$ were the actual point, then the reflection $M'$ of $M$ on $XY$ gives the same $f(X)$ and $f(Y)$. Thus two queries are not enough.


Part iii)

Pinpointing the vertices is impossible! Any rotation of the $ABC$ around the centroid gives the same $f(P)$ values.


 

Tuesday, January 20, 2026

An unexpected approach to a quadratic system of equations

Positive reals $a,b,c$ satisfy

$$ a^2 + b^2  + ab = 121$$

$$b^2 + c^2 + bc = 169$$

$$ c^2 + a^2 + ca = 400$$


What is the value of $ab + bc + ca$?

.

.

.

.

.

.

This can be solved using geometry!


Consider triangle $OAB$ with $OA = a$ and $OB = b$ and $\angle{AOB} = 120^{\circ}$.

Using cosine rule, $AB^2 = a^2 + b^2 - 2ab \cos(120^{\circ}) = a^2 + b^2 + ab$. Thus $AB = 11$.

Area of triangle $AOB$ = $\frac{1}{2} ab \sin(120^{\circ}) = \frac{\sqrt{3}}{4} ab$

Now add point $C$ such that $OC = c$ and $\angle{AOC} = \angle{COB} = 120^{\circ}$.

We thus have a triangle $ABC$ with sides $AB = 11, BC = 13, AC = 20$ and area  (by adding up areas of $AOB, AOC, BOC$


 $$\frac{\sqrt{3}}{4} (ab + bc + ca)$$


By Heron's formula, since the sides are known, we get area $=66$.

This gives $$ab + bc + ca = 88 \sqrt{3}$$

Tuesday, November 25, 2025

A magic trick with 2 magicians and 3 spectators

 Show that the following magic trick is possible.

Two magicians call three spectators and have them sit on three chairs. One magician (call them B), goes out of the room. The other magician (A) spreads out 27 cards in front of the spectators, and each is asked to take a card of their choice. 

Once the spectators choose, A points to a card from the remaining 24 and has the spectators add it to their set of three cards (i.e. A does not touch that card). The spectators are allowed to shuffle the four cards. B is then called back and one of the spectators hands B the four shuffled cards. Looking at the 4 cards, B now announces which spectator chose which card.

.

.

.

.

.

Solution:

Lets label the chairs (and hence the spectators) 1,2,3. The magicians agree upon this before hand.

There are $6 \binom{27}{3} =17550$ possibilities for spectators cards. The number of possibilities for the 4 cards handed to B is $\binom{27}{4} = 17550$. Thus we need to find a pairing for each possibility of the spectator's pick to a 4 element superset.

Now look at this as a bipartite graph.

One vertex set is the set of spectator possibilities (call it $S$) and the other is the set of 4 elements subsets (call if $F$).

Each spectator possibility $s \in S$ has exactly 24 neighbours in $F$. Each 4 element set $f \in F$ has exactly $6\binom{4}{3} = 24$ neighbours in the spectator set $S$.

This is a regular bi-partite graph and by a simple application of Hall's theorem, has a perfect matching. 

A brief sketch is:

If $L$ is a subset of $S$ and $N(L) \subset F$ is the set of neighbours of $L$, then the number of edges in the induced subgraph of $G(L, N(L))$ is $24|L|$. Since the degree of each vertex of $F$ is 24, the degree of the $F$ vertices in $G(L, N(L))$ is at most $24$. Thus we must have that $24 |N(L)| \ge 24 |L|$ and thus $|N(L)| \ge |L|$, satisfying the condition of hall's theorem. 



Friday, October 31, 2025

Cute problem from Moldova Math Olympiad

 $a,b$ are real numbers that satisfy


$$a^3 - 3ab^2 = 29$$

$$b^3 - 3a^2b = 34$$


What is the value of $a^2 + b^2$?

Meta puzzle: Which year did this problem appear?

.

.

.

.

Solution:


The solution becomes simple if you think complex!

$$(a+ib)^3 = (a^3 - 3ab^2) - i(b^3 - 3a^2b)$$

Thus $$(a+ib)^3 = 29 - 34i$$


And so $$(a^2 + b^2)^3 = 29^2 + 34^2 = 1997$$

and

$$a^2 + b^2 = \sqrt[3]{1997}$$

Note that we basically have the identity


$$(a^2 + b^2)^3 = (a^3 - 3ab^2)^2 + (b^3 - 3a^2b)^2$$

Tuesday, October 28, 2025

Sum of consecutive positive integers

 A classic.


Show that integers of the form $2^m$ are the only positive integers that cannot be written as the sum of two or more consecutive positive integers.

.

.

.

.

Solution:

Suppose we try to write $X$ as the sum of consecutive positive integers.

$$X =  a + (a+1) + \dots + (a+n)$$ 

i.e.

$$2X = (n+2a)(n+1)$$

Note, since we need two or more, we must have that $n > 0$, and $n + 2a > n+1$.

Note that $n+2a$ and $n+1$ are of different parities.

If $X$ was a power of $2$, then the only way we can factor $2X$ into factors of different parities is if one of them is $1$. But we have $n+1 \ge 2$. So, powers of $2$ cannot be written in that form.

For any other $X  = 2^m Y$ ($Y > 1$, odd), we can pick the factors to be $2^{m+1}$ and $Y$ and compute the appropriate $n$ and $a$.

Monday, October 27, 2025

Integral perimeter and Hypotenuse problem

 The IOQM seems to have some nice problems, though the solutions given by the many of the Indian book authors/coaching classes are sometimes wrong and/or lacking for the harder problems.

Here is a problem where one of the books got the wrong answer, even though the problem isn't hard.


The altitude dropped on the hypotenuse of a right triangle is the integer $12$. Given that the hypotenuse and the perimeter of the triangle are integers too, what is the smallest possible length of the hypotenuse?

.

.

.

Solution:


If $c$ is the hypotenuse (and $a,b$ are the legs), then we have that $12 c = ab$ (by equating the area of the triangle). $a+b+c$ and $c$ are both integers.

We also have that $(a+b)^2$ is a perfect square.

$$(a+b)^2 = a^2 + b^2 + 2ab = c^2 + 24c$$

By imagining a semicircle of diameter $c$, we can easily see that $c \ge 24$, and note that for any $c \ge 24$, a right triangle exists.

Now $c^2 + 24c$ has to a perfect square, and $c=25$ is the smallest that works.

The book had the answer as $24$ which is wrong.


Tuesday, September 2, 2025

Distinct Remainders, a problem from IOQM.

 Here is a cute problem for IOQM.


What is the smallest $n$ such that $1^4, 2^4, \dots , 14^4$ all leave distinct remainders when divided by $n$?




Solution.


Now $x^4 - y^4$ = $(x-y)(x+y)(x^2+y^2)$, we want this to be non-zero $\mod n$.

If $n \lt 28$, then we can find distinct $x, y \le 14$ such tht $x+y = n$.

We also have that $(13+1)(13-1)$ is divisible by $28$.

$29 = 5^2 + 2^2$

$(11+1)(11-1)$ is divisible by $30$.

Now consider $n=31$. For $31$ to not be a candidate we must have that $x^2+y^2$ is divisible by $31$.

But, it is well known that if $p$ is a prime of the form $4m+3$, and it divides $x^2+y^2$, then it divides $x$ and $y$.


Thus $31$ is our answer.

Monday, August 4, 2025

A cute problem form India's UPSC exam

 UPSC is India's civil services exam, and surprisingly, the following cute problem appeared. Admittedly, it was a multiple choice question, and could be guessed easily.

Anyway, here is the question:

$a,b,c$ are positive integers such that 

$$\dfrac{bc + 1}{abc + a + c} = \frac{11}{43}$$

Then what are the possible values of $abc$?



Solution.

We can find all solutions. In fact there is a unique solution.

Take the reciprocal and do some minor algebra to get


$$a + \dfrac{c}{bc + 1} = \dfrac{43}{11} = 3 + \dfrac{10}{11}$$ 

Since $\frac{c}{bc + 1} \lt 1$, we must have that $a=3$ and $\frac{c}{bc+1} = \frac{10}{11}$.

Taking reciprocal again gives

$$b + \dfrac{1}{c} = \dfrac{11}{10} = 1 + \dfrac{1}{10}$$

$c = 1$ is not possible (LHS is an integer, while RHS is not). Thus $\frac{1}{c} \lt 1$ and so

$b = 1$ and $c=10$

Thus $(a,b,c) = (3,1,10)$ is the unique solution and $abc = 30$.


Saturday, August 2, 2025

Powers of 2 series convergence from Peter Winkler

 Here is a cute problem from Peter Winkler.

The series below converges in the interval $[0,1)$


$$ x - x^2 + x^4 - x^8 + \dots + (-1)^n x^{2^n} + \dots $$


For $x \in [0, 1)$, call the value $f(x)$.

The question is, does the limit 

$$ \lim_{x \to 1-} f(x) $$

exist?




Solution.

A proof by Noam Elkies goes as follows (rephrased, not verbatim):

We can show that for $x \in [0,1)$, 


$$f(x) + f(x^2) = x $$

and so (by a repeated application of the above)

$$ f(x) = x - x^2 + f(x^4)$$

By the first identity, if the limit exists, it must be $\frac{1}{2}$.

Now for $0 \lt x \lt 1$ we must have that (using the second identity above)

$$ f(x) \gt f(x^4) \gt f(x^{16}) \gt \dots \gt f(x^{4^n}) \gt \dots$$

Thus if there was some $c$ such that $f(c) \gt \frac{1}{2}$, we must have that

$$f(c^{4^{-n}}) \gt f(c) \gt \frac{1}{2}$$

And since $c^{4^{-n}} \to 1$ as $n \to \infty$, the limit cannot be $\frac{1}{2}$ if $f(c) \gt \frac{1}{2}$.

A quick computation (wrote python code) upto $15$ terms shows that $f(0.9999) \gt 0.5006$.