cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

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

Views

Author

Altug Alkan, Mar 29 2018

Keywords

Comments

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.
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, ...
From Robert Israel, Mar 29 2018: (Start)
If n >= 1 is a square, then a(n) = sqrt(n).
If n is not a square but 8*n+1 is a square, then f(n) = (sqrt(8*n+1)+1)/2.
If n >= 3 and neither n nor 8*n+1 is a square, then a(n) > sqrt(3*n+1).
For n >= 3, n and a(n) are not coprime. (End)
From Bob Andriesse, Jan 02 2024: (Start)
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.
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)

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.
		

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; ))}