Find the lowest positive integer that has its digits reversed after dividing it by 2.
The following program does not find anything:
DECLARE FUNCTION verify! (a$, b$)
FOR n = 1 TO 999999
n$ = LTRIM$(STR$(n))
IF verify(n$, "01258") = 0 THEN
h$ = ""
FOR j = 1 TO LEN(n$)
d$ = MID$(n$, j, 1)
IF d$ = "5" THEN d$ = "2": ELSE IF d$ = "2" THEN d$ = "5"
h$ = d$ + h$
NEXT
h = VAL(h$)
IF 2 * h = n THEN PRINT n
END IF
NEXT
FUNCTION verify (a$, b$)
FOR i = 1 TO LEN(a$)
IF INSTR(b$, MID$(a$, i, 1)) = 0 THEN verify = i: EXIT FUNCTION
NEXT
verify = 0
END FUNCTION
|
Posted by Charlie
on 2004-07-15 11:18:31 |