The minimum value is 341:
clearvars,clc
for n=2:1000
if powermod(2,n,n)-2==0
if powermod(3,n,n)-3~=0
disp([n sym(2)^n-2 sym(3)^n-3])
disp([mod(sym(2)^n-2,n) mod(sym(3)^n-3,n)])
end
end
end
finds
[3, 6, 24]
[0, 0]
[341, 4479489484355608421114884561136888556243290994469299069799978201927583742360321890761754986543214231550,
4992842419769444411575714115125880074355727994157202873032702852991828893873287975661182639605572486502613841657
002635137622031360394139015053716643508803196884400]
[0, 165]
[645, 1459980997639102469965174913824093223965833122319539177785341605727768053506776763681892099621558847929165
53906355021033942038551084014015944085162231110854024063829579528478402651974151891320830,
5536168426744474969056605767077275545903010474061201280187469375477066817845613707129407014030377528307254782772
5214059372529764661566971136719387709460315091508388244902662699700782731942327365191482722530805276999897722717
401064024162241228376033289769245635612231268185763210043415291409656410067969574640]
[0, 105]
The first set was a ringer: the taking of the mod was done before the subtraction of 2 or 3, so after the subtraction of 3, the value was -3. However, in the check calculation the true mod value of the difference was shown to be 0.
Therefore the real minimum value meeting the conditions is 341, where 2^341-2 mod 341 is 0 and 3^341-3 mod 341 is 165.
The second case is N=645, shown as the loop tried through n=1000.
|
Posted by Charlie
on 2023-06-19 14:38:51 |