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-3 of 3 results.

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

Original entry on oeis.org

0, 0, 2, 2, 4, 4, 6, 6, 0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8, 15, 14, 13, 12, 3, 2, 1, 0, 7, 6, 5, 4, 32, 32, 34, 34, 36, 36, 38, 38, 32, 33, 34, 35, 36, 37, 38, 39, 43, 42, 41, 40, 47, 46, 45, 44, 35, 34, 33, 32, 39, 38, 37, 36, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Offset: 0

Views

Author

Rémy Sigrist, Dec 08 2019

Keywords

Examples

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

Crossrefs

See A330270 for the square variant.
See A330272 for the OR variant.

Programs

  • Mathematica
    A330271[n_] := Module[{k = -1}, While[!IntegerQ[CubeRoot[BitXor[n, ++k]]]]; k];
    Array[A330271, 100, 0] (* Paolo Xausa, Feb 20 2024 *)
  • PARI
    a(n) = for (k=0, oo, if (ispower(bitxor(n,k),3), return (k)))
    
  • Python
    from itertools import count
    from sympy import integer_nthroot
    def A330271(n): return next(k for k in count(0) if integer_nthroot(n^k,3)[1]) # Chai Wah Wu, Aug 23 2023

Formula

a(n) = 0 iff n is a cube.

A344220 a(n) is the least k >= 0 such that n XOR k is a binary palindrome (where XOR denotes the bitwise XOR operator).

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 2, 3, 2, 1, 0, 1, 0, 3, 2, 1, 0, 3, 2, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 3, 2, 5, 4, 7, 6, 5, 4, 7, 6, 1, 0, 3, 2, 3, 2, 1, 0, 7, 6, 5, 4, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 3, 2, 5, 4, 7, 6, 1, 0, 3, 2, 5, 4, 7, 6, 5, 4, 7, 6, 1, 0, 3
Offset: 0

Views

Author

Rémy Sigrist, May 12 2021

Keywords

Comments

The binary expansions of n and of n XOR a(n) have the same length, say k, and their first ceiling(k/2) bits are the same.

Examples

			For n=42:
- 42 XOR 0 = 42 ("101010" in binary) is not a binary palindrome,
- 42 XOR 1 = 43 ("101011" in binary) is not a binary palindrome,
- 42 XOR 2 = 40 ("101000" in binary) is not a binary palindrome,
- 42 XOR 3 = 41 ("101001" in binary) is not a binary palindrome,
- 42 XOR 4 = 46 ("101110" in binary) is not a binary palindrome,
- 42 XOR 5 = 47 ("101111" in binary) is not a binary palindrome,
- 42 XOR 6 = 44 ("101100" in binary) is not a binary palindrome,
- 42 XOR 7 = 45 ("101101" in binary) is a binary palindrome,
- so a(42) = 7.
		

Crossrefs

Programs

  • Mathematica
    A344220[n_] := Module[{k = -1}, While[!PalindromeQ[IntegerDigits[BitXor[n, ++k], 2]]];k]; Array[A344220, 100, 0] (* Paolo Xausa, Feb 19 2024 *)
  • PARI
    a(n) = my (b); for (k=0, oo, if ((b=binary(bitxor(n, k)))==Vecrev(b), return (k)))
    
  • Python
    from itertools import count
    def A344220(n): return next(k for k in count(0) if (s := bin(n^k)[2:])[:(t:=len(s)+1>>1)]==s[:-t-1:-1]) # Chai Wah Wu, Aug 23 2023

Formula

a(n) = 0 iff n belongs to A006995.
A070939(n XOR a(n)) = A070939(n).
A344259(n XOR a(n)) = A344259(n).

A331961 a(n) is the greatest square number k such that n AND k = k (where AND denotes the bitwise AND operator).

Original entry on oeis.org

0, 1, 0, 1, 4, 4, 4, 4, 0, 9, 0, 9, 4, 9, 4, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 25, 16, 25, 16, 25, 16, 25, 0, 1, 0, 1, 36, 36, 36, 36, 0, 9, 0, 9, 36, 36, 36, 36, 16, 49, 16, 49, 36, 49, 36, 49, 16, 49, 16, 49, 36, 49, 36, 49, 64, 64, 64, 64, 64, 64, 64
Offset: 0

Views

Author

Rémy Sigrist, Feb 02 2020

Keywords

Examples

			The first terms, alongside the binary representations of n and of a(n), are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     0      10          0
   3     1      11          1
   4     4     100        100
   5     4     101        100
   6     4     110        100
   7     4     111        100
   8     0    1000          0
   9     9    1001       1001
  10     0    1010          0
  11     9    1011       1001
  12     4    1100        100
  13     9    1101       1001
  14     4    1110        100
  15     9    1111       1001
  16    16   10000      10000
		

Crossrefs

Programs

  • PARI
    a(n) = forstep (m=sqrtint(n), 0, -1, if (bitand(n, m^2)==m^2, return (m^2)))
    
  • Python
    from math import isqrt
    def A331961(n): return next(m for m in (k**2 for k in range(isqrt(n),-1,-1)) if n&m==m) # Chai Wah Wu, Aug 22 2023

Formula

a(n) = 0 iff n belongs to A062880.
a(n^2) = n^2.
Showing 1-3 of 3 results.