# Wild About Math!Making Math fun and accessible

10May/087

## Monday Math Madness #5: We have a winner

We have a winner for MMM #5 and a new contest to be announced Monday at Blinkdagger.

We received 24 entries, one came after the deadline, so only the 23 that met the deadline were considered. All solutions were correct and well explained. Random.org picked the winner.

Congratulations, Janet! You win the \$25 gift certificate to the Art of Problem Solving. They have outstanding quality Math books. I doubt you’d be disappointed with anything you buy from them.

Janet, if you send me your solution as a Word doc, or in text format, I’ll post it here.

Everyone figured out that 1 and 9 are the only perfect squares with all odd digits. Everyone also noted that all odd perfect squares must have an even tens digit, thus no perfect square with a tens digit can have all odd digits. Several people also noted that 1 and 9 are really 01 and 09, and since 0 is an even digit, 1 and 9 also follow the pattern that all odd perfect squares have an even tens digit. We, of course, don’t even consider even perfect squares because we’re looking for perfect squares with all odd digits.

Maurizio Codogno has a simple and short proof that all odd squares greater than 9 have an even digit:

1 and 9 are the only perfect squares whose digits are all odd. Actually, I’ll show a stronger result: namely, that the two least significative digits of any perfect square cannot both be odd. (Of course, 1 and 9 do not have two significative digits; not have two significative digits; that's why they are exceptions!)

Let's write an integer n in the form 10d+u, where u is a digit between 0 and 9. Its square is 100d^2 +20du + u^2. The first component plays no role in calculating the last two digits. The second component modifies only the number of tens, and it always has an even number of tens (2du is always even). As for u^2, it is even if u is even, so we must only consider u odd. The squares of odd digits are 1, 9, 25, 49, 81; all of them have an even number of tens, so the total number of tens is even.

Samjshah missed the deadline but blogged about it, providing a brute force solution.

Gareth McCaughan had an interesting response and a proof that differed from all the others:

The one-digit squares are 0,1,4,9. Of these, only 1 and 9 qualify. Any other square whose digits are all odd has at least 2 digits and therefore is congruent mod 100 to something both of whose digits are odd.

At this point, we could try to reduce the amount of brute-force checking needed by some clever brainwork, but computer cycles are cheap, so:

for i in range(100):
sq = i*i
a,b = sq%10, (sq//10)%10
if a&b&1: print i,sq

and lo and behold, no output is generated.

... Oh, all right, I'll show how to do it with a bit less brute force. An odd square is 1 mod 4, and any square is 0, 1, or 4 mod 5. So there are only three possibilities mod 20: 5, 1, 9 respectively. Note that all these have an even tens digit, and so anything congruent mod 20 to any of them has too. In particular, any square with an odd units digit has an even tens digit, and we're done.

A couple of people pointed out that the theorem is not true in every base. Craig Wiegert pointed out that in base 8, 3*3 = 11 and 5*5 = 31, both of which have all odd digits. So, there's an interesting exploration here for those so inclined: for which bases is the conjecture true?

Mr. K did some of this exploration using a computer script:

It struck me that (a) this proof didn't really expose much about the numbers or their squares, and (b) since it asked about digits, it was really about the nature of base 10 notation.

I turned to my computer, and wrote a quick script to analyze the first 10000 squares in bases from 2 to 50. The results are interesting, even if I didn't gain a lot of further insight.

Bases 2, 4, 10 and 12 never had any multi digit squares with only odd digits.
Base 6 had one: 9 => 13
Base 3 had two: 3 => 11 & 121 => 11111
Base 5 had 5: 16 => 31, 81 => 311 841 => 11331, 285156 => 33111111, 519831 => 113113331

The last suggests that although rare, there is no upper bound for odd digit only squares for base 5. All the others had several such squares, with the count increasing as the range of squares was increased. There was also no immediately discernible pattern pattern for higher bases: base 27 had 300 such squares in the first 100, base 28 had 84, and base 30 had 45. There was a continuing upward trend, however, suggesting that the interesting cases where odd digit only primes never happen are in the bases of 12 and below.

Here are the 23 folks that submitted a correct and timely solution. Leave your URL in a comment and I'll update the post to give you a little link love.

• S S
• Maurizio Codogno
• Joshua Zucker
• Anneleen Van Geenhoven
• Richard Berlin
• Daniel Bahls
• Chin hui han
• Andrew Bromage
• Kelvin Heng
• Craig Wiegert
• Lieven Marchand
• Tanaeem M Moosa
• Denise
• Efrit Freeq
• Marijn Jongerden
• Gareth McCaughan
• Pierluigi and Jonatha
• Janet
• Mr. K
• Anand
• Immanuel McLaughlin
• Andreas Bonelli
• Ingmar Dasseville

Thank you, everyone who participated in this contest.

Check out Blinkdagger on Monday for another fun Math problem.

1. Hi can you please post the full proof of Maurizio Codogno. Thanks 🙂

2. Sorry about that. I’ve added the few words that were cut off at the end.

3. Hi good guys at MMM..could the frequency of the problems be increased from once every two weeks to weekly? Otherwise there will always be a week which i can’t get my MMM fix..(shivers from withdrawal symptoms) 😛

4. Aww… so close…

5. The Julia Robinson Mathematics Festivals were successes this year, if I do say so myself. Just came back from the second, at Pixar in Emeryville. Please link to http://jrmathfestival.org for my winning entry here!

Thanks!

6. Joshua,