OFFSET
2,2
COMMENTS
Inspired by A302245.
While A302245 is completely predictable, this sequence behaves relatively complex.
Least positive nonsquarefree term is a(139) = 5^2*11.
If a(n) > a(n-1), then n is prime and a(n+1) = a(n). Values of a(n) such that a(n+2) > a(n+1) = a(n) > a(n-1) are 3, 7, 43, 69, 103, 259, 343, 463, 523, ...
Numbers n such that a(n) > a(n-1) are 3, 5, 7, 13, 19, 29, 31, 41, 43, 53, 59, ...
EXAMPLE
a(2) = 0 because only option is p = q = 2.
a(3) = 3 because 3^2 mod 6 = 3 is the largest remainder.
MAPLE
Primes:= {}:
A[2]:= 0:
for n from 3 to 200 do
if not isprime(n) then A[n]:= A[n-1]
else
Primes:= Primes union {n};
A[n]:= max(A[n-1], seq(p*n mod (p+n), p=Primes))
fi
od:
seq(A[n], n=2..200); # Robert Israel, Apr 08 2018
MATHEMATICA
a[n_] := Max@ Flatten@ Table[p=Prime[i]; q=Prime[j]; Mod[p q, p + q], {i, PrimePi[n]}, {j, i}]; Array[a, 75, 2]
PROG
(PARI) first(n) = {my(t = 1, u = nextprime(n+1), bet = vector(primepi(u)), res = List(vector(u)), p, q); forprime(p = 2, u, forprime(q = 2, p, r = (p*q) % (p+q); for(i = t, #bet, bet[i] = max(bet[i], r))); t++); t = 1; p = 2; forprime(q = 3, u, for(i = p, q - 1, res[i] = bet[t]); p = q; t++); res[u] = bet[t]; listpop(res, 1); res} \\ David A. Corneth, Apr 08 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Altug Alkan and Andres Cicuttin, Apr 08 2018
STATUS
approved