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

Home > Numbers
Singular squares (Posted on 2008-11-23) Difficulty: 2 of 5
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.)
Solution 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             1
4             2
9             3
16            4
25            5
36            6
49            7
169           13
256           16
289           17
1369          37
13456         116
13689         117
134689        367

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

and:


1             1
4             2
9             3
64            8
81            9
841           29
961           31

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


  Posted by Charlie on 2008-11-23 17:43:16
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (7)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information