Is there a “Fermat” in you? ? :-)

Fermat’s problem:

Pierre de Fermat (1601-65), the great French mathematical genius, is described as the “Prince of Amateurs” as he was not a professional mathematician and never published any work during his lifetime. As a civil servant, he served in the judiciary and spent his leisure with mathematics as his hobby. He corresponded with the best of mathematicians of his time. He teased the contemporary English mathematicians, Wallis and Digby, with the following problem, who had to admit defeat.


26 is a number that is sandwiched between a perfect square (25) and a perfect cube (27). Prove that there is no other such number.

Please do try and let me know your solutions. Even partial solutions are welcome.


Nalin Pithwa.

Happy Numbers make Happy Programmers ! :-)

Here is one question which one of my students, Vedant Sahai asked me. It appeared in his computer subject exam of his recent ICSE X exam (Mumbai):

write a program to accept a number from the user, and check if the number is a happy number or not; and the program has to display a message accordingly:

A Happy Number is defined as follows: take a positive number and replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (one). If the number ends with 1, then it is called a happy number.

For example: 31

Solution : 31 replaced by 3^{2}+1^{2}=10 and 10 replaced by 1^{2}+0^{2}=1.

So, are you really happy? 🙂 🙂 🙂


Nalin Pithwa.

Yet another special number !

The eminent British mathematician had once remarked: Every integer was a friend to Srinivasa Ramanujan.

Well, we are mere mortals, yet we can cultivate some “friendships with some numbers”. Let’s try:


Squaring 12 gives 144. By reversing the digits of 144, we notice that 441 is also a perfect square. Using C, C++, or python, write a program to find all those integers m, such that 1 \leq m \leq N, verifying this property.

PS: in order to write some simpler version of the algorithm, start playing with small, particular values of N.

Reference: 1001 Problems in Classical Number Theory, Indian Edition, AMS (American Mathematical Society), Jean-Marie De Konick and Armel Mercier.

Amazon India link:


Nalin Pithwa.


Fundamental theorem of algebra: RMO training

It is quite well-known that any positive integer can be factored into a product of primes in a unique way, up to an order. (And, that 1 is neither prime nor composite) —- we all know this from our high school practice of “tree-method” of prime factorization, and related stuff like Sieve of Eratosthenes. But, it is so obvious, and so why it call it a theorem, that too “fundamental” and yet it seems it does not require a proof. It was none other than the prince of mathematicians of yore, Carl Friedrich Gauss, who had written a proof to it. It DOES require a proof — there are some counter example(s). Below is one, which I culled for my students:


Let E= \{a+b\sqrt{-5}: a, b \in Z\}

(a) Show that the sum and product of elements of E are in E.

(b) Define the norm of an element z \in E by ||z||=||a+b\sqrt{-5}||=a^{2}+5b^{2}. We say that an element p \in E is prime if it is impossible to write p=n_{1}n_{2} with n_{1}, n_{2} \in E, and ||n_{1}||>1, ||n_{2}||>1; we say that it is composite if it is not prime. Show that in E, 3 is a prime number and 29 is a composite number.

(c) Show that the factorization of 9 in E is not unique.


Nalin Pithwa.

A Special Number


Show that for each positive integer n equal to twice a triangular number, the corresponding expression \sqrt{n+\sqrt{n+\sqrt{n+ \sqrt{n+\ldots}}}} represents an integer.


Let n be such an integer, then there exists a positive integer m such that n=(m-1)m=m^{2}-m. We then have n+m=m^{2} so that we have successively

\sqrt{n+m}=m; \sqrt{n + \sqrt{n+m}}=m; \sqrt{n+\sqrt{n+\sqrt{n+m}}}=m and so on. It follows that

\sqrt{n+\sqrt{n+\sqrt{n+ \sqrt{n+\ldots}}}}=m, as required.

Comment: you have to be a bit aware of properties of triangular numbers.


1001 Problems in Classical Number Theory by Jean-Marie De Koninck and Armel Mercier, AMS (American Mathematical Society), Indian Edition:

Amazon India link:


Nalin Pithwa.

Another cute proof: square root of 2 is irrational.

Reference: Elementary Number Theory, David M. Burton, Sixth Edition, Tata McGraw-Hill.

(We are all aware of the proof we learn in high school that \sqrt{2} is irrational. (due Pythagoras)). But, there is an interesting variation of that proof.

Let \sqrt{2}=\frac{a}{b} with gcd(a,b)=1, there must exist integers r and s such that ar+bs=1. As a result, \sqrt{2}=\sqrt{2}(ar+bs)=(\sqrt{2}a)r+(\sqrt{2}b)s=2br+2bs. This representation leads us to conclude that \sqrt{2} is an integer, an obvious impossibility. QED.

RMO 2017 Warm-up: Two counting conundrums

Problem 1:

There are n points in a circle, all joined with line segments. Assume that no three (or more) segments intersect in the same point. How many regions inside the circle are formed in this way?

Problem 2:

Do there exist 10,000 10-digit numbers divisible by 7, all of which can be obtained from one another by a re-ordering of their digits?

Solutions will be put up in a couple of days.

Nalin Pithwa.


Learning Number Theory — like Paul Halmos did

I find that many of my very young “kids” are fascinated to number theory as soon as I start teaching it to them in a ‘friendly’ way, or by way of  “numerical experiments” and then getting them hooked to solving classics in number theory for RMO (Regional mathematics olympiad) and INMO (Indian National Mathematics Olympiad). There is a rich variety of backgrounds of these students here in India.

But, if you (my reader/or my current student/ or even my past student) would like to pick it up in a more serious manner, I reproduce below the famous mathematician, Paul Halmos’ experience as a graduate student (Ref; I want to be a mathematician, An Automathography by Paul Halmos) (his advice is, of course, useful to students pursuing their undergraduate in math, or computer science or also, or those preparing for competitive exams like AMC, AIME, etc.) or even graduate students in such disciplines): Here it is:

…R. D. Carmichael was one of the outstanding members Illinois department. He told me that for a period of a several years there were only three mathematicians on earth who published more than 100 pages a year: G. D. Birkhoff, N. E. Norfund, and himself. His lectures were supremely organized, clearly delivered, inspiring. When I learned from him that 2^{2^{5}}+1 \equiv \mod 641, I rushed home and entered that in my diary. He wrote several books and kept publishing a lot (mainly differential equations), I admired him and wanted to be like him in as many ways as I could. His handwritten p, for instance, was idiosyncratic (the vertical stroke extended almost as far above the level of the loop as below), and I adopted it; to  this day, my p’s look odd.

I fell in love with number theory in Carmichael’s course. He made us prepare a table whose row headings were the first 400 positive integers, and whose column headings, about 25 of them, were items like factorization, sums of squares, sums of primes. Our instructions were to fill in the table, and then proceed to guess (and if possible, prove) as many theorems as we could.

My first research was inspired by Carmichael. He told us about a peculiar question (inspired by perhaps by the four square theorem): for which positive integers a, b, c, d is it true that every positive integer is representable by the form ax^{2}+by^{2}+cz^{2}+dt^{2}(Representable means via integral values of the variables x, y, z, t.) The answer is that there are exactly 54 such forms, and Srinivas Ramanujan determined them all. My question was: which forms of the same kind represent every positive integer with exactly one exception ? I found 88 candidates, proved that there could be no others, and proved that 86 of them actually worked. (Example: x^{2}+y^{2}+2z^{2}+29t^{2} fails to represent 14 only.) The two I could not decide were later settled by Gordon Pall: both x^{2}+2y^{2}+7z^{2}+11t^{2} and x^{2}+2y^{2}+7z^{2}+13t^{2} fail to represent 5 only. No inspiration was needed for this, my first published research, only patience and diligent application of  the techniques Carmichael taught me, but the work gave me a feeling of accomplishment and (badly needed) the confidence that I could do research. I was very proud. I bought 200 reprints; it took me years to find enough people to give them to.


By the way, an immortal mathematican, Carl Friedrich Gauss used to say (something like this): Mathematics is the queen of all sciences, and number theory it’s best field. Gauss held number theory in high esteem.

🙂 🙂 🙂

-Nalin Pithwa.