A224515 a(n) = least k such that sqrt(k^2 XOR (k+1)^2) = 2*n+1, a(n) = -1 if there is no such k.
0, 4, 3, 24, 23, 44, 43, 112, 111, 180, 76, 264, 248, 348, 164, 480, 479, 411, 611, 327, 183, 115, 139, 943, 1103, 747, 787, 1111, 1447, 323, 699, 1984, 1983, 1851, 2243, 2008, 1576, 1388, 1684, 1072, 976, 1268, 499, 3383, 3271, 4124, 4068, 3679, 4511, 4315, 3804, 4999
Offset: 0
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 0..1000
Crossrefs
Cf. A221643.
Programs
-
Mathematica
a[n_] := For[k=0, k <= 3*n^2+1, k++, If[ Sqrt[ BitXor[k^2, (k+1)^2]] == 2*n+1, Return[k]]] /. Null -> -1; a /@ Range[0, 51] (* Jean-François Alcover, Jun 05 2013 *)
-
PARI
a(n)=my(k=sqrtint(2*n^2),t);while(!issquare(bitxor(k^2,(k+1)^2),&t)||t!=2*n+1,k++);k \\ Charles R Greathouse IV, Jun 05 2013
-
Python
import math needTerms = n = 1024 i = 0 terms = [-1] * n while n: s = (i*i) ^ ((i+1)*(i+1)) r = int(math.sqrt(s)) if s == r*r: if (r&1)==0: break r = (r-1)//2 if r < needTerms: if terms[r] >= 0: break terms[r] = i n -= 1 i += 1 if n: print('Error') else: for i in range(needTerms): t = terms[i] print(t, end=', ') # math.sqrt((t*t) ^ ((t+1)*(t+1)))
Comments