login
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.
1
-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,3
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.
LINKS
Interactive scatterplot of (x, y, z) such that x^2 XOR y^2 = z^2 and x, y, z < 2^13 [provided your web browser supports the Plotly library, you should see icons on the top right corner of the page: if you choose "Orbital rotation", then you will be able to rotate the plot alongside three axes]
EXAMPLE
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.
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 *)
PROG
(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
CROSSREFS
Cf. A055527.
Sequence in context: A105342 A323601 A055525 * A309046 A007568 A091884
KEYWORD
sign,base
AUTHOR
Rémy Sigrist, Feb 22 2024
STATUS
approved