OFFSET
0,1
COMMENTS
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
FORMULA
Empirically, for any k > 1, a(2*k+1) = a(2*k)-1.
EXAMPLE
For n = 44:
- 44 XOR 0 = 44 is not prime,
- 44 XOR 1 = 45 is not prime,
- 44 XOR 2 = 46 is not prime,
- 44 XOR 3 = 47 is prime,
- hence a(44) = 3.
MAPLE
f:= proc(n) local k;
for k from 0 do if isprime(Bits:-Xor(k, n)) then return k fi od
end proc:
map(f, [$0..200]); # Robert Israel, Nov 27 2017
MATHEMATICA
Table[Block[{k = 0}, While[! PrimeQ@ BitXor[k, n], k++]; k], {n, 0, 104}] (* Michael De Vlieger, Nov 26 2017 *)
PROG
(PARI) a(n) = for (k=0, oo, if (isprime(bitxor(n, k)), return (k)))
(Python)
from itertools import count
from sympy import isprime
def A295520(n): return next(k for k in count(0) if isprime(n^k)) # Chai Wah Wu, Aug 23 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 23 2017
STATUS
approved