## Project Euler 206: Find the unique positive integer for a concealed square

#### Problem Description

Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,

where each “_” is a single digit.

#### Analysis

The square of any number, *n*, will end in 00 if the last digit of *n* is zero. So, our square root ends in a zero and the square has the form 1_2_3_4_5_6_7_8_900.

We can reduce our search to 1_2_3_4_5_6_7_8_9 and multiply the square root (when we find it) by 10. Now, the only way to end a square with 9 is to square a number ending with 3 or 7. OK, so our square root ends with 3 or 7, an odd number, and we can skip even-numbered *n* from consideration.

Let’s begin our search with the maximum possible number, 1__9__2__9__3__9__4__9__5__9__6__9__7__9__8__9__9 and take its square root. Starting with an odd number we count down by 2 until the square fits our pattern.

#### Project Euler 206 Solution

Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 206 Solution Python 2.7 source.

#### Answer

Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose*define*to reveal the answer.

#### Afterthoughts

- The square root can only be a 9 digit integer that starts with 1 and ends with 0.

*Project Euler 206 Solution last updated*

I do like your approach to matching. I came here because I couldn’t see what was wrong with my solution. As it happens, I was offering the square rather than the square root. 🙁

Thanks, Bill. Glad it helped.

The assumption made is incompletely justified for the problem statement

The question asks for the number whose square is 1_2_3…_9_0

There is no explicit guarantee that n ends in 0, only that n^2 ends in 0.

A better rationale is that there is no value other than a multiple of 10, that when multiplied by itself which gives x0, thus n must be divisible by 10

Phil, if someone planted an explosive device under your chair and told you that to disarm it all you had to do was type in any integer ending with a zero that, when squared, would not end with a zero would you be blown left or right from the concussion?

PHIL GOT PWNT!!!!