Determine all possible value(s) of a 15-digit base ten positive integer N which is constituted entirely by the digits 2 and 3, such that N is divisible by the base ten
repunit R
7.
DECLARE SUB build ()
DEFDBL A-Z
DIM SHARED dig(15), placeVal, psn, tot
placeVal = 100000000000000#: psn = 1
build
SUB build
FOR d = 2 TO 3
dig(psn) = d
tot = tot + d * placeVal
IF psn = 15 THEN
q = INT(tot / 1111111)
totMod = tot - q * 1111111
IF totMod = 0 THEN
FOR i = 1 TO 15
PRINT dig(i);
NEXT
PRINT , q
END IF
ELSE
psn = psn + 1: placeVal = placeVal / 10
build
psn = psn - 1: placeVal = placeVal * 10
END IF
tot = tot - d * placeVal
NEXT
END SUB
finds
2 3 3 3 3 3 3 2 3 3 3 3 3 3 2 210000012
being the digits of the answer and the quotient upon dividing by 1111111.
|
Posted by Charlie
on 2010-01-07 15:57:38 |