Only two of the optionally true statements are true: EIGHT is even and EIGHT - 1 is a prime.
ONE, FOUR and NINE are 361, 2304, 6561 respectively.
EIGHT and EIGHTEEN are 15798 and 15798116.
THREE is 89411.
... and RIGHT is 45798.
DECLARE SUB factor (num#, s$)
DEFDBL A-Z
CLS
FOR t = 1 TO 9
taken(t) = 1
FOR o = 1 TO 9
IF taken(o) = 0 THEN
taken(o) = 1
FOR f = 1 TO 9
IF taken(f) = 0 THEN
taken(f) = 1
FOR n = 1 TO 9
IF taken(n) = 0 THEN
taken(n) = 1
FOR e = 1 TO 9
IF taken(e) = 0 THEN
taken(e) = 1
one = o * 100 + n * 10 + e
sr = INT(SQR(one) + .5)
IF sr * sr = one THEN
FOR u = 0 TO 9
IF taken(u) = 0 THEN
taken(u) = 1
FOR r = 0 TO 9
IF taken(r) = 0 THEN
taken(r) = 1
four = f * 1000 + o * 100 + u * 10 + r
sr = INT(SQR(four) + .5)
IF sr * sr = four THEN
FOR i = 0 TO 9
IF taken(i) = 0 THEN
taken(i) = 1
nine = 1010 * n + 100 * i + e
sr = INT(SQR(nine) + .5)
IF sr * sr = nine THEN
FOR g = 0 TO 9
IF taken(g) = 0 THEN
taken(g) = 1
FOR h = 0 TO 9
IF taken(h) = 0 THEN
three = t * 10000 + h * 1000 + r * 100 + e * 11
eight = e * 10000 + i * 1000 + g * 100 + h * 10 + t
eighteen = eight * 1000 + 110 * e + n
tCt = 0
IF t MOD 2 = 0 THEN tCt = tCt + 1
ep1 = eight + 1
sr = INT(SQR(ep1) + .5)
IF sr * sr = ep1 THEN tCt = tCt + 1
ep1 = eight + one
sr = INT(SQR(ep1) + .5)
IF sr * sr = ep1 THEN tCt = tCt + 1
em1 = eight - 1
factor em1, s$
s$ = LTRIM$(RTRIM$(s$))
IF INSTR(s$, " ") = 0 THEN tCt = tCt + 1
em1 = eight - one
factor em1, s$
s$ = LTRIM$(RTRIM$(s$))
IF INSTR(s$, " ") = 0 THEN tCt = tCt + 1
ep7 = eight + 7
factor ep7, s$
s$ = LTRIM$(RTRIM$(s$))
ix = INSTR(s$, " ")
IF ix THEN
s$ = LTRIM$(MID$(s$, ix + 1))
IF INSTR(s$, " ") = 0 THEN tCt = tCt + 1
END IF
IF eighteen MOD 3 = 0 THEN tCt = tCt + 1
IF eighteen MOD three = 0 THEN tCt = tCt + 1
em2 = eight - 2
sr = INT(SQR(em2) + .5)
IF sr * sr = em2 THEN tCt = tCt + 1
IF tCt > 1 THEN
PRINT tCt
right = r * 10000 + i * 1000 + g * 100 + h * 10 + t
PRINT one, four, nine
PRINT eight, eighteen
PRINT three
PRINT right
REM
END IF
END IF
NEXT
taken(g) = 0
END IF
NEXT g
END IF ' nine is perfect square
taken(i) = 0
END IF
NEXT i
END IF ' four is perfect square
taken(r) = 0
END IF
NEXT
taken(u) = 0
END IF
NEXT u
END IF ' one a perfect square
taken(e) = 0
END IF
NEXT
taken(n) = 0
END IF
NEXT
taken(f) = 0
END IF
NEXT
taken(o) = 0
END IF
NEXT
taken(t) = 0
NEXT
SUB factor (num, s$)
s$ = "": n = ABS(num): IF n > 0 THEN limit = SQR(n): ELSE limit = 0
IF limit <> INT(limit) THEN limit = INT(limit + 1)
dv = 2: GOSUB DivideIt
dv = 3: GOSUB DivideIt
dv = 5: GOSUB DivideIt
dv = 7
DO UNTIL dv > limit
GOSUB DivideIt: dv = dv + 4 '11
GOSUB DivideIt: dv = dv + 2 '13
GOSUB DivideIt: dv = dv + 4 '17
GOSUB DivideIt: dv = dv + 2 '19
GOSUB DivideIt: dv = dv + 4 '23
GOSUB DivideIt: dv = dv + 6 '29
GOSUB DivideIt: dv = dv + 2 '31
GOSUB DivideIt: dv = dv + 6 '37
LOOP
IF n > 1 THEN s$ = s$ + STR$(n)
EXIT SUB
DivideIt:
DO
q = INT(n / dv)
IF q * dv = n AND n > 0 THEN
n = q
s$ = s$ + STR$(dv)
IF n > 0 THEN limit = SQR(n): ELSE limit = 0
IF limit <> INT(limit) THEN limit = INT(limit + 1)
ELSE
EXIT DO
END IF
LOOP
RETURN
END SUB
From Enigma # 1425 by Susan Denham, New Scientist, 13 January 2007.
|