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.

Showing 1-2 of 2 results.

A330270 a(n) is the least nonnegative integer k such that n XOR k is a square (where XOR denotes the bitwise XOR operator).

Original entry on oeis.org

0, 0, 2, 2, 0, 1, 2, 3, 1, 0, 3, 2, 5, 4, 7, 6, 0, 1, 2, 3, 4, 5, 6, 7, 1, 0, 3, 2, 5, 4, 7, 6, 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1
Offset: 0

Views

Author

Rémy Sigrist, Dec 08 2019

Keywords

Comments

This sequence has similarities with A329794 as the XOR operator and the "box" operator defined in A329794 both map (n, n) to 0 for any n (however here we accept 0 as a square).

Examples

			For n = 7,
- 7 XOR 0 = 7 (not a square),
- 7 XOR 1 = 6 (not a square),
- 7 XOR 2 = 5 (not a square),
- 7 XOR 3 = 4 = 2^2,
- hence a(7) = 3.
		

Crossrefs

See A330271 for the cube variant.

Programs

  • Mathematica
    A330270[n_] := Module[{k = -1}, While[!IntegerQ[Sqrt[BitXor[n, ++k]]]]; k];
    Array[A330270, 100, 0] (* Paolo Xausa, Feb 19 2024 *)
  • PARI
    a(n) = for (k=0, oo, if (issquare(bitxor(n, k)), return (k)))
    
  • Python
    from itertools import count
    from sympy.ntheory.primetest import is_square
    def A330270(n): return next(k for k in count(0) if is_square(n^k)) # Chai Wah Wu, Aug 22 2023

Formula

a(n) = 0 iff n is a square.
a(a(n)) <= n.

A330272 a(n) is the least nonnegative integer k such that n OR k is a cube (where OR denotes the bitwise OR operator).

Original entry on oeis.org

0, 0, 25, 24, 121, 120, 337, 336, 0, 18, 17, 16, 113, 112, 3361, 3360, 11, 10, 9, 8, 105, 104, 321, 320, 3, 2, 1, 0, 97, 96, 29761, 29760, 93, 92, 1297, 1296, 89, 88, 3337, 3336, 85, 84, 3333, 3332, 81, 80, 3329, 3328, 77, 76, 1281, 1280, 73, 72, 59265, 59264
Offset: 0

Views

Author

Rémy Sigrist, Dec 08 2019

Keywords

Comments

The sequence is well defined:
- for any k >= 0, the binary expansion of m = A000225(k)^3 has k trailing 1's,
- hence for any n < 2^k, n OR m = m, which is a cube, QED.

Crossrefs

See A330271 for the XOR variant.

Programs

  • Mathematica
    A330272[n_] := Module[{k = -1}, While[!IntegerQ[CubeRoot[BitOr[n, ++k]]]]; k];
    Array[A330272, 60, 0] (* Paolo Xausa, Feb 20 2024 *)
  • PARI
    See Links section.

Formula

a(n) = 0 iff n is a cube.
a(n) AND n = 0 (where AND denotes the bitwise AND operator).
Showing 1-2 of 2 results.