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

 5-Digit Squares (Posted on 2009-12-06)

 No Solution Yet Submitted by brianjn No Rating

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

DEFDBL A-Z
CLS
FOR a = 100 TO 998
a2 = a * a: IF a2 > 99999 THEN EXIT FOR

s\$ = LTRIM\$(STR\$(a2))
good = 1
FOR i = 1 TO 4
FOR j = i + 1 TO 5
IF MID\$(s\$, i, 1) = MID\$(s\$, j, 1) THEN good = 0: EXIT FOR
NEXT
IF good = 0 THEN EXIT FOR
NEXT

IF good THEN

FOR b = a + 1 TO 999
b2 = b * b: IF b2 > 99999 THEN EXIT FOR
c2 = a2 + b2: IF c2 > 99999 THEN EXIT FOR
sr = INT(SQR(c2) + .5)

IF sr * sr = c2 THEN

s\$ = LTRIM\$(STR\$(b2))
s1\$ = LTRIM\$(STR\$(c2))
good = 1
FOR i = 1 TO 4
FOR j = i + 1 TO 5
IF MID\$(s1\$, i, 1) = MID\$(s1\$, j, 1) THEN good = 0: EXIT FOR
IF MID\$(s\$, i, 1) = MID\$(s\$, j, 1) THEN good = 0: EXIT FOR
NEXT
IF good = 0 THEN EXIT FOR
NEXT

IF good THEN
PRINT a2, b2, c2
PRINT a, b, sr
PRINT
END IF

END IF

NEXT b

END IF

NEXT a

finds

`18496         74529         93025136           273           305`

with the 5-digit squares on top and A, B and C below. Note that the program doesn't check that all 10 digits have been used, but the answer is still unique.

 Posted by Charlie on 2009-12-06 21:44:55
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 (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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