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.

A370574 a(n) is the least k > 0 such that n^2 XOR k^2 is a positive square number (where XOR denotes the bitwise XOR operator), or -1 if no such k exists.

Original entry on oeis.org

-1, -1, 4, 3, 3, 8, 24, 6, 23, 6, 44, 16, 43, 48, 36, 12, 111, 46, 180, 12, 72, 88, 9, 7, 7, 86, 20, 59, 20, 72, 56, 24, 479, 222, 20, 15, 20, 360, 15, 24, 183, 144, 13, 11, 11, 18, 943, 14, 1103, 14, 747, 172, 405, 40, 159, 31, 492, 40, 28, 144, 28, 112, 31, 48, 660
Offset: 1

Views

Author

Rémy Sigrist, Feb 22 2024

Keywords

Comments

This sequence has similarities with A055527; here we look for triples (n, k, m) of positive integers such that n^2 XOR k^2 = m^2, there for triples such that n^2 + k^2 = m^2.
Conjecture: a(n) > 0 for any n > 2.

Examples

			For n = 6: we have:
  k   6^2 XOR k^2  Positive square?
  --  -----------  ----------------
   1           37  No
   2           32  No
   3           45  No
   4           52  No
   5           61  No
   6            0  No
   7           21  No
   8          100  Yes
So a(6) = 8.
		

Crossrefs

Cf. A055527.

Programs

  • Maple
    f:= proc(n) local k;
      for k from 1 by 1 do if k <> n and issqr(MmaTranslator[Mma]:-BitXor(n^2, k^2)) then return k fi od
    end proc: f(1):= -1: f(2):= -1:
    map(f, [$1..100]); # Robert Israel, Mar 01 2024
  • Mathematica
    A370574[n_] := If[n <= 2, -1, Block[{k = 0}, While[++k == n || !IntegerQ[ Sqrt[BitXor[n^2, k^2]]]]; k]]; Array[A370574, 100] (* Paolo Xausa, Mar 01 2024 *)
  • PARI
    a(n) = { if (n <= 2, return (-1), for (k = 1, oo, if (k!=n &&  issquare( bitxor(n^2, k^2)), return (k)););); }
    
  • Python
    from sympy import integer_nthroot
    def A370574(n):
        if n <= 2: return -1
        k, n_2 = 1, n**2
        while True:
            if (integer_nthroot(n_2 ^ k**2, 2))[1] and k != n: return k
            k += 1 # Karl-Heinz Hofmann, Mar 03 2024