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

A295793 a(n) is the least k such that A295520(k) = n.

Original entry on oeis.org

2, 4, 0, 8, 25, 24, 35, 34, 201, 200, 203, 202, 297, 296, 299, 298, 1335, 1334, 1333, 1332, 1331, 1330, 1329, 1328, 3295, 3294, 3293, 3292, 3291, 3290, 3289, 3288, 11749, 11748, 11761, 11760, 11745, 11744, 11765, 11764, 11757, 11756, 19623, 19622, 11753, 11752, 19619, 19618, 25475, 25474, 25473, 25472
Offset: 0

Views

Author

Robert Israel, Nov 27 2017

Keywords

Examples

			a(3)=8 because A295520(8)=3 and this is the first appearance of 3 in A295520.
		

Crossrefs

Cf. A295520.

Programs

  • Maple
    N:= 100: # to get a(0)..a(N)
    A295520:= proc(n) local k;
      for k from 0 do if isprime(Bits:-Xor(k,n)) then return k fi od
    end proc:
    V:= Array(0..N,-1):
    count:= 0:
    for n from 0 while count < N+1 do
    r:= A295520(n);
    if r <= N and V[r]=-1 then
       count:= count+1; V[r]:= n
    fi
    od:
    convert(V,list); # Robert Israel, Nov 27 2017
  • Mathematica
    With[{s = Array[Block[{k = 0}, While[! PrimeQ@ BitXor[k, #], k++]; k] &, 10^6]}, FirstPosition[s, #][[1]] /. 1 -> 0 & /@ Take[#, LengthWhile[Differences@ #, # == 1 &]] &@ Union@ s] (* Michael De Vlieger, Nov 27 2017 *)
  • Python
    from itertools import count
    from sympy import isprime
    def A295793(n): return next(k for k in count(0) if next((m for m in range(n+1) if isprime(k^m)),None)==n) # Chai Wah Wu, Aug 23 2023

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.

A295335 a(n) = least k >= 0 such that n OR k is prime (where OR denotes the bitwise OR operator).

Original entry on oeis.org

2, 2, 0, 0, 1, 0, 1, 0, 3, 2, 1, 0, 1, 0, 17, 16, 1, 0, 1, 0, 3, 2, 1, 0, 5, 4, 5, 4, 1, 0, 1, 0, 5, 4, 9, 8, 1, 0, 9, 8, 1, 0, 1, 0, 3, 2, 1, 0, 5, 4, 9, 8, 1, 0, 73, 72, 3, 2, 1, 0, 1, 0, 65, 64, 3, 2, 1, 0, 3, 2, 1, 0, 1, 0, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 43
Offset: 0

Views

Author

Rémy Sigrist, Nov 23 2017

Keywords

Comments

See A295609 for the corresponding prime numbers.
We can show that this sequence is well defined by using Dirichlet's theorem on arithmetic progressions.
a(n) = 0 iff n is prime.
For any n >= 0, n AND a(n) = 0 (where AND denotes the bitwise AND operator).
If a(n) = x + y with x AND y = 0, then a(n + x) = y.
This sequence has similarities with A007920: here we check n OR k, there we check n + k.
See A295520 for the XOR variant.
For any k > 0, a(2^(6*k)-1) >= 2^(6*k) (hence the sequence is unbounded).

Examples

			For n = 42, 42 OR 0 = 42 is not prime, 42 OR 1 = 43 is prime, hence a(42) = 1.
		

Crossrefs

Programs

  • Mathematica
    Table[Block[{k = 0}, While[! PrimeQ@ BitOr[k, n], k++]; k], {n, 0, 84}] (* Michael De Vlieger, Nov 26 2017 *)
  • PARI
    avoid(n,i) = if (i, if (n%2, 2*avoid(n\2,i), 2*avoid(n\2,i\2)+(i%2)), 0) \\ (i+1)-th number k such that k AND n = 0
    a(n) = for (i=0, oo, my (k=avoid(n,i)); if (isprime(n+k), return (k)))

Formula

For any k > 1, a(2*k+1) = a(2*k)-1.

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).
Showing 1-4 of 4 results.