A301941 a(n) is the smallest positive integer k such that n + k divides n^2 + k, or 0 if no such k exists.
1, 1, 0, 3, 2, 5, 4, 7, 6, 3, 5, 11, 10, 13, 12, 6, 4, 17, 16, 19, 18, 7, 11, 23, 22, 5, 24, 12, 8, 29, 28, 31, 30, 11, 17, 35, 6, 37, 36, 18, 12, 41, 40, 43, 42, 10, 23, 47, 46, 7, 20, 24, 16, 53, 52, 11, 14, 19, 29, 59, 58, 61, 60, 30, 8, 15, 12, 67, 66, 23, 35, 71, 70, 73, 72, 36, 19, 56, 13, 79, 78, 9, 41, 83, 82, 17, 84
Offset: 0
Examples
a(2) = 0 because there is no positive k such that k + 2 divides k + 4. a(15) = 6 because 15 + 6 = 3*7 divides 15^2 + 6 = 3*7*11 and 6 is the least positive integer with this property.
Links
- Altug Alkan, Table of n, a(n) for n = 0..10000
Crossrefs
Cf. A053626.
Programs
-
Maple
f:= proc(n) local k; if issqr(n) then return sqrt(n) fi; for k from ceil(sqrt(2*n)) do if (n^2+k) mod (n+k) = 0 then return k fi od end proc: f(2):= 0: f(0):= 1: map(f, [$0..100]); # Robert Israel, Mar 29 2018
-
Mathematica
a[n_] := If[n == 2, 0, If[PrimeQ[n], n, Module[{k = 1}, While[Mod[n^2+k, n+k] != 0, k++]; k]]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Feb 10 2023, from PARI code *)
-
PARI
a(n) = {if(n==2, 0, if(isprime(n), n, my(k=1); while((n^2+k) % (n+k) != 0, k++); k; ))}
Comments