ABC and CBA are two three-digit decimal numbers, with A and C different non-zero digits. Squares of these numbers are five-digit numbers DEFGH and HGFED respectively. Find all such three-digit numbers.
Attempting to find solutions where each letter represented a different digit, I found none. So assigning the same digit to different letters was allowed.
However, A and C are specified to be different from each other. The solutions which fit that are:
ABC CBA DEFGH HGFED
102 201 10404 40401
103 301 10609 90601
112 211 12544 44521
113 311 12769 96721
122 221 14884 48841
201 102 40401 10404
211 112 44521 12544
221 122 48841 14884
301 103 90601 10609
311 113 96721 12769
were it not for the requirement that A and C be different, the following would have worked:
101 101 10201 10201
111 111 12321 12321
121 121 14641 14641
202 202 40804 40804
212 212 44944 44944
DEFDBL A-Z
CLS
FOR a = 1 TO 9
FOR b = 0 TO 9
FOR c = 1 TO 9
IF c <> a THEN
abc = 100 * a + 10 * b + c
cba = 100 * c + 10 * b + a
abc2 = abc * abc
cba2 = cba * cba
abc2s$ = LTRIM$(STR$(abc2))
cba2s$ = LTRIM$(STR$(cba2))
IF LEN(abc2s$) = 5 AND LEN(cba2s$) = 5 THEN
good = 1
FOR i = 1 TO 5
IF MID$(abc2s$, i, 1) <> MID$(cba2s$, 6 - i, 1) THEN good = 0: EXIT FOR
NEXT
IF good THEN PRINT abc; cba, abc2; cba2
END IF
END IF
NEXT
NEXT
NEXT
PRINT : PRINT
FOR a = 1 TO 9
FOR b = 0 TO 9
FOR c = 1 TO 9
IF c = a THEN
abc = 100 * a + 10 * b + c
cba = 100 * c + 10 * b + a
abc2 = abc * abc
cba2 = cba * cba
abc2s$ = LTRIM$(STR$(abc2))
cba2s$ = LTRIM$(STR$(cba2))
IF LEN(abc2s$) = 5 AND LEN(cba2s$) = 5 THEN
good = 1
FOR i = 1 TO 5
IF MID$(abc2s$, i, 1) <> MID$(cba2s$, 6 - i, 1) THEN good = 0: EXIT FOR
NEXT
IF good THEN PRINT abc; cba, abc2; cba2
END IF
END IF
NEXT
NEXT
NEXT
|
Posted by Charlie
on 2013-02-12 17:49:03 |