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.

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.

This page as a plain text file.
%I A224515 #17 Feb 01 2025 14:58:29
%S A224515 0,4,3,24,23,44,43,112,111,180,76,264,248,348,164,480,479,411,611,327,
%T A224515 183,115,139,943,1103,747,787,1111,1447,323,699,1984,1983,1851,2243,
%U A224515 2008,1576,1388,1684,1072,976,1268,499,3383,3271,4124,4068,3679,4511,4315,3804,4999
%N 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.
%C A224515 Conjectures:
%C A224515 1. a(n) >= 0.
%C A224515 2. Least k is also the only such k.
%C A224515 If both conjectures are true, then the sequence is a permutation of A221643.
%H A224515 Charles R Greathouse IV, <a href="/A224515/b224515.txt">Table of n, a(n) for n = 0..1000</a>
%t A224515 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 *)
%o A224515 (Python)
%o A224515 import math
%o A224515 needTerms = n = 1024
%o A224515 i = 0
%o A224515 terms = [-1] * n
%o A224515 while n:
%o A224515   s = (i*i) ^ ((i+1)*(i+1))
%o A224515   r = int(math.sqrt(s))
%o A224515   if s == r*r:
%o A224515     if (r&1)==0:  break
%o A224515     r = (r-1)//2
%o A224515     if r < needTerms:
%o A224515         if terms[r] >= 0:  break
%o A224515         terms[r] = i
%o A224515         n -= 1
%o A224515   i += 1
%o A224515 if n:  print('Error')
%o A224515 else:
%o A224515   for i in range(needTerms):
%o A224515     t = terms[i]
%o A224515     print(t, end=', ') # math.sqrt((t*t) ^ ((t+1)*(t+1)))
%o A224515 (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
%Y A224515 Cf. A221643.
%K A224515 nonn,base,less
%O A224515 0,2
%A A224515 _Alex Ratushnyak_, Apr 08 2013