A172038 Smallest nonnegative integer such that n + (a(n))^2 is a perfect square, or -1 if no such integer exists.
0, -1, 1, 0, 2, -1, 3, 1, 0, -1, 5, 2, 6, -1, 1, 0, 8, -1, 9, 4, 2, -1, 11, 1, 0, -1, 3, 6, 14, -1, 15, 2, 4, -1, 1, 0, 18, -1, 5, 3, 20, -1, 21, 10, 2, -1, 23, 1, 0, -1, 7, 12, 26, -1, 3, 5, 8, -1, 29, 2, 30, -1, 1, 0, 4, -1, 33, 16, 10, -1, 35, 3, 36, -1, 5, 18, 2, -1, 39, 1, 0, -1, 41, 4, 6
Offset: 1
Keywords
Examples
a(7) = 3 because 7 + 1 = 8 and 7 + 4 = 11 are not perfect squares, but 7 + 9 = 16 is.
Programs
-
Maple
A172038 := proc(n) local r,kpa,kma,a,k ; r := {} ; for kpa in numtheory[divisors](n) do kma := n/kpa ; if type(kpa-kma,'even') then a := (kpa-kma)/2 ; k := kpa- a; if a >= 0 and k >= 0 and kpa+kma = 2*k then r := r union {a}; end if; end if; end do ; if r <> {} then return min(op(r)) ; else return -1 ; end if; end proc: for n from 1 to 100 do printf("%d,",A172038(n)) ; end do : # R. J. Mathar, Feb 07 2010
Extensions
More terms from R. J. Mathar, Feb 07 2010
Comments