A287016 a(n) = smallest number k such that A071904(n) + k^2 is a perfect square.
0, 1, 2, 0, 3, 4, 1, 5, 2, 0, 7, 3, 8, 1, 4, 10, 5, 2, 0, 6, 13, 3, 14, 7, 1, 4, 17, 9, 2, 5, 0, 19, 10, 20, 6, 3, 22, 1, 12, 7, 4, 13, 25, 8, 2, 0, 5, 9, 28, 29, 16, 3, 6, 1, 32, 11, 18, 7, 4, 34, 19, 12, 35, 2, 0, 5, 21, 38, 9, 14, 3, 40, 6, 1, 15, 10, 24
Offset: 1
Examples
The third odd composite number is A071904(3) = 21. and 21+2^2 = 25 = 5^2, so a(3) = 2.
Programs
-
Mathematica
q[n_] := SelectFirst[Range[0, (n-1)/2], IntegerQ@ Sqrt[#^2 + n] &]; q /@ Select[Range[1, 300, 2], CompositeQ] (* Giovanni Resta, May 18 2017 *)
-
Python
from sympy import primepi, divisors from sympy.ntheory.primetest import is_square def A287016(n): if n == 1: return 0 m, k = n, primepi(n) + n + (n>>1) while m != k: m, k = k, primepi(k) + n + (k>>1) return 0 if is_square(int(m)) else -(d:=divisors(m))[l:=(len(d)>>1)-1]+d[l+1]>>1 # Chai Wah Wu, Aug 02 2024
Formula
a(m) = 0 for m>0 in A037040, the corresponding odd composites being in A016754\{1}. - Michel Marcus, May 19 2017
Extensions
More terms from Giovanni Resta, May 18 2017