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.

Original entry on oeis.org

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

Views

Author

Alex Ratushnyak, Apr 08 2013

Keywords

Comments

Conjectures:
1. a(n) >= 0.
2. Least k is also the only such k.
If both conjectures are true, then the sequence is a permutation of A221643.

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