Determine the probability that for a base ten positive integer N drawn at random between 2 and 101 inclusively, the number N3 + 1 is expressible in the form p*q*r, where p, q, r are three distinct positive integers such that p, q and r (in this order) corresponds to three consecutive terms of an arithmetic sequence.
The probability is 5%, as there are only 5 values of n that work: 3, 12, 27, 48 and 75.
start diff seq. product n-formula
1 3: 1 4 7 28 3^3+1
7 6: 7 13 19 1729 12^3+1
19 9: 19 28 37 19684 27^3+1
37 12: 37 49 61 110593 48^3+1
61 15: 61 76 91 421876 75^3+1
It was more efficient to try all possible arithmetic sequences rather than trying all possible n's and trying to factor the enhanced cubes. The starting number in the sequence couldn't be higher than 101, but 102 was used for good measure. The difference between terms of the sequence couldn't be higher than 1015 as higher would exceed 101^3+1 even if starting at 1. When starting higher than 1, the inner loop is exited as soon as products start to exceed the limit.
DEFDBL A-Z
DIM yes(101)
limit = 101 ^ 3 + 1
FOR st = 1 TO 102
FOR diff = 1 TO 1016
prod = 1
FOR i = st TO st + 2 * diff STEP diff
prod = prod * i
NEXT
IF prod > limit THEN EXIT FOR
cube = prod - 1
cr = INT(cube ^ (1 / 3) + .5)
IF cr * cr * cr = cube AND cr > 1 AND cr < 102 THEN
PRINT USING "### ###: ## ## ## ####### ###&"; st; diff; st; st + diff; st + 2 * diff; cube + 1; cr; "^3+1"
yes(cr) = 1
END IF
NEXT diff
NEXT st
tot = 0
FOR i = 2 TO 101
tot = tot + yes(i)
NEXT
PRINT tot
|
Posted by Charlie
on 2010-03-11 13:45:10 |