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.

A359946 Lexicographically earliest sequence of distinct positive integers such that for any n > 0, n XOR a(n) is a prime number (where XOR denotes the bitwise XOR operator).

This page as a plain text file.
%I A359946 #6 Jan 21 2023 16:25:10
%S A359946 2,1,4,3,6,5,10,11,12,7,8,9,14,13,16,15,18,17,20,19,22,21,26,27,28,23,
%T A359946 24,25,30,29,34,35,36,31,32,33,38,37,42,43,44,39,40,41,46,45,48,47,50,
%U A359946 49,52,51,54,53,58,59,60,55,56,57,62,61,64,63,66,65,68
%N A359946 Lexicographically earliest sequence of distinct positive integers such that for any n > 0, n XOR a(n) is a prime number (where XOR denotes the bitwise XOR operator).
%C A359946 This sequence is a self-inverse permutation of the positive integers.
%C A359946 See A359947 for the corresponding prime numbers.
%C A359946 When considering nonnegative integers instead of positive integers, we obtain A004443.
%H A359946 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%e A359946 The first terms, alongside n XOR a(n), are:
%e A359946   n   a(n)  n XOR a(n)
%e A359946   --  ----  ----------
%e A359946    1     2           3
%e A359946    2     1           3
%e A359946    3     4           7
%e A359946    4     3           7
%e A359946    5     6           3
%e A359946    6     5           3
%e A359946    7    10          13
%e A359946    8    11           3
%e A359946    9    12           5
%e A359946   10     7          13
%e A359946   11     8           3
%e A359946   12     9           5
%t A359946 nn = 2^10; c[_] := False; a[1] = 2; c[2] = True; u = 1; Do[k = u; While[Nand[! c[k], PrimeQ@ BitXor[n, k]], k++]; Set[{a[n], c[k]}, {k, True}]; If[k == u, While[c[u], u++]], {n, 2, nn}]; Array[a, nn] (* _Michael De Vlieger_, Jan 21 2023 *)
%o A359946 (PARI) { s = 0; for (n=1, 67, for (v=1, oo, if (!bittest(s, v) && isprime(bitxor(n, v)), print1 (v", "); s += 2^v; break))) }
%Y A359946 Cf. A004443, A359947.
%K A359946 nonn,base
%O A359946 1,1
%A A359946 _Rémy Sigrist_, Jan 19 2023