login
a(n) is the smallest positive integer k such that n + k divides n^2 + k, or 0 if no such k exists.
3

%I #37 Feb 20 2024 13:28:28

%S 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,

%T 8,29,28,31,30,11,17,35,6,37,36,18,12,41,40,43,42,10,23,47,46,7,20,24,

%U 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

%N a(n) is the smallest positive integer k such that n + k divides n^2 + k, or 0 if no such k exists.

%C If even n > 2, such positive k exists and a(n) <= n - 2 since n^2 + n - 2 = (n + 2)*(n - 1) is divisible by n + n - 2 = 2*(n - 1). Additionally, a(2) = 0 because such positive k does not exist. So a(n) <= n - 2 for even positive n.

%C 1 <= a(n) <= n for odd n, in particular, a(p) = p if p is an odd prime and it is also possible that a(t) = t for some composite t. Composite numbers t such that a(t) = t are 35, 95, 119, 143, 203, 215, 247, 275, 299, 335, 395, 403, 437, ...

%C From _Robert Israel_, Mar 29 2018: (Start)

%C If n >= 1 is a square, then a(n) = sqrt(n).

%C If n is not a square but 8*n+1 is a square, then f(n) = (sqrt(8*n+1)+1)/2.

%C If n >= 3 and neither n nor 8*n+1 is a square, then a(n) > sqrt(3*n+1).

%C For n >= 3, n and a(n) are not coprime. (End)

%C From _Bob Andriesse_, Jan 02 2024: (Start)

%C Proof that a(n) = n, if n is an odd prime: Consider any odd n and choose k = n, then (n^2+k)/(n+k) becomes n*(n+1)/(2n), which is an integer. So a(n) = k <= n, for odd n. If n+k = z then k = z-n and n+k | n^2 + k is equivalent to z | n^2 + z-n or z | n^2 - n. So n+k | n*(n-1). If n is an odd prime and k < n, then n+k must divide n-1, which is impossible. Therefore k >= n. We already know that k <= n, so k = n if n is an odd prime p, or a(p) = p.

%C a(n) is also the smallest k > 0 such that n+k divides n*(k+1), k*(k+1), n*(n-1), k*(n-1) and k^2-n, or 0 if no such k exists. Example: 15+6 divides 15*(6+1), 6*(6+1), 15*(15-1), 6*(15-1) and 6^2-15. (End)

%H Altug Alkan, <a href="/A301941/b301941.txt">Table of n, a(n) for n = 0..10000</a>

%e a(2) = 0 because there is no positive k such that k + 2 divides k + 4.

%e 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.

%p f:= proc(n) local k;

%p if issqr(n) then return sqrt(n) fi;

%p for k from ceil(sqrt(2*n)) do if (n^2+k) mod (n+k) = 0 then return k fi od

%p end proc:

%p f(2):= 0: f(0):= 1:

%p map(f, [$0..100]); # _Robert Israel_, Mar 29 2018

%t a[n_] := If[n == 2, 0, If[PrimeQ[n], n, Module[{k = 1}, While[Mod[n^2+k, n+k] != 0, k++]; k]]];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Feb 10 2023, from PARI code *)

%o (PARI) a(n) = {if(n==2, 0, if(isprime(n), n, my(k=1); while((n^2+k) % (n+k) != 0, k++); k; ))}

%Y Cf. A053626.

%K nonn,easy,look

%O 0,4

%A _Altug Alkan_, Mar 29 2018