The letters E, G, H, I, N, S, T, V, and X represent different digits 09 (Neither S nor E is 0). SIX is a three digit number equal to the product of two consecutive integers, SEVEN is a five digit prime number, and EIGHT is a five digit perfect cube. What numbers are SIX, SEVEN and EIGHT?
The following program only checks SEVEN for divisibility by primes up to 19, but that narrows it down sufficiently to test the primality of SEVEN by other means:
DIM used(9)
FOR s = 1 TO 9
used(s) = 1
FOR i = 0 TO 9
IF used(i) = 0 THEN
used(i) = 1
FOR x = 0 TO 9
IF used(x) = 0 THEN
used(x) = 1
six = 100 * s + 10 * i + x
sr1 = INT(SQR(six))
IF sr1 * (sr1 + 1) = six THEN
FOR e = 1 TO 9
IF used(e) = 0 THEN
used(e) = 1
FOR g = 0 TO 9
IF used(g) = 0 THEN
used(g) = 1
FOR h = 0 TO 9
IF used(h) = 0 THEN
used(h) = 1
FOR t = 0 TO 9
IF used(t) = 0 THEN
used(t) = 1
eight = (((e * 10 + i) * 10 + g) * 10 + h) * 10 + t
cr = INT(eight ^ (1 / 3) + .5)
IF cr * cr * cr = eight THEN
FOR v = 0 TO 9
IF used(v) = 0 THEN
used(v) = 1
FOR n = 0 TO 9
IF used(n) = 0 THEN
used(n) = 1
seven = (((s * 10 + e) * 10 + v) * 10 + e) * 10 + n
IF seven MOD 2 > 0 AND seven MOD 3 > 0 AND seven MOD 5 > 0 AND seven MOD 7 > 0 THEN
IF seven MOD 11 > 0 AND seven MOD 13 > 0 AND seven MOD 17 > 0 AND seven MOD 19 > 0 THEN
PRINT six, seven, eight
END IF
END IF
used(n) = 0
END IF
NEXT n
used(v) = 0
END IF
NEXT v
END IF
used(t) = 0
END IF
NEXT t
used(h) = 0
END IF
NEXT h
used(g) = 0
END IF
NEXT g
used(e) = 0
END IF
NEXT e
END IF
used(x) = 0
END IF
NEXT x
used(i) = 0
END IF
NEXT i
used(s) = 0
NEXT s
The results are:
380 36467 68921
420 43139 32768
420 43531 32768
420 43931 32768
930 91517 13824
In only the first instance is the middle number, SEVEN, prime, as
43139=179*241
43531=101*431
43931=197*223
91517=23*23*173

Posted by Charlie
on 20051005 14:42:32 