All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Singular squares (Posted on 2008-11-23)
What is the greatest perfect square with different digits in ascending order from left to right?

The same, in descending order?

What is the best way to narrow this search?

 See The Solution Submitted by pcbouhid No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 2 of 3 |

DEFDBL A-Z
max = SQR(9999999999#)
FOR i = 1 TO max
s = i * i
sq\$ = LTRIM\$(STR\$(s))
good = 1
FOR j = 2 TO LEN(sq\$)
IF MID\$(sq\$, j, 1) <= MID\$(sq\$, j - 1, 1) THEN good = 0: EXIT FOR
NEXT
IF good THEN PRINT s, i
NEXT

FOR i = 1 TO max
s = i * i
sq\$ = LTRIM\$(STR\$(s))
good = 1
FOR j = 2 TO LEN(sq\$)
IF MID\$(sq\$, j, 1) >= MID\$(sq\$, j - 1, 1) THEN good = 0: EXIT FOR
NEXT
IF good THEN PRINT s, i
NEXT

finds

`1             14             29             316            425            536            649            7169           13256           16289           171369          3713456         11613689         117134689        367`

as the squares that fit the first pattern, shown with their roots. The largest is 134689.

and:

`1             14             29             364            881            9841           29961           31`

as the squares fitting the second pattern, the largest being 961.

 Posted by Charlie on 2008-11-23 17:43:16

 Search: Search body:
Forums (0)