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.

A182310 a(0)=0, a(n+1) = (a(n) XOR floor(a(n)/2)) + 1, where XOR is the bitwise exclusive-or operator.

This page as a plain text file.
%I A182310 #42 Jul 22 2025 08:43:39
%S A182310 0,1,2,4,7,5,8,13,12,11,15,9,14,10,16,25,22,30,18,28,19,27,23,29,20,
%T A182310 31,17,26,24,21,32,49,42,64,97,82,124,67,99,83,123,71,101,88,117,80,
%U A182310 121,70,102,86,126,66,100,87,125,68,103,85,128,193,162,244,143
%N A182310 a(0)=0, a(n+1) = (a(n) XOR floor(a(n)/2)) + 1, where XOR is the bitwise exclusive-or operator.
%C A182310 As n -> infinity, a(n) -> infinity.
%H A182310 Reinhard Zumkeller, <a href="/A182310/b182310.txt">Table of n, a(n) for n = 0..10000</a>
%H A182310 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/XOR.html">XOR</a>
%H A182310 Wikipedia, <a href="http://en.wikipedia.org/wiki/Binary_and#XOR">Bitwise operation XOR</a>
%F A182310 a(n) = A105081(a(n-1)+1). - _Jon Maiga_, Jun 27 2021
%e A182310 a(5) = ( a(4) XOR floor(a(4)/2) ) + 1 = (7 XOR 3) + 1 = 4+1 = 5.
%p A182310 a:= proc(n) option remember; `if`(n=0, 0, 1+
%p A182310      (t-> Bits[Xor](t, iquo(t, 2)))(a(n-1)))
%p A182310     end:
%p A182310 seq(a(n), n=0..100);  # _Alois P. Heinz_, Jun 29 2021
%t A182310 NestList[BitXor[#,Floor[#/2]]+1&,0,70] (* _Harvey P. Dale_, Apr 18 2015 *)
%o A182310 (C)
%o A182310 #include <stdio.h>
%o A182310 #include <math.h>
%o A182310 typedef unsigned long long ULL;
%o A182310 int main(int argc, char **argv) {
%o A182310   ULL a=0, i=0, p, prev;
%o A182310   while(1) {
%o A182310     prev = a,   a = (a^(a/2)) + 1;
%o A182310   #if 0  // "if 1" to print indices of 2^x
%o A182310     ++i;
%o A182310     if ( (i & ((1<<30)-1))==0 )  printf(".");
%o A182310     if ((a^prev) > prev)
%o A182310        printf("\n%llu at %llu,  log2: %llu ", a, i, (ULL)(100.0*log2(i)));
%o A182310   #else
%o A182310     printf("%llu, ", prev);
%o A182310   #endif
%o A182310     // Test reversion:
%o A182310     p=a-1;
%o A182310     ULL t=p/2;
%o A182310     while (t)  p^=t, t/=2;
%o A182310     if (p!=prev) printf("Reversion failed!"), exit(1);
%o A182310   }
%o A182310   return 0;
%o A182310 }  // from _Alex Ratushnyak_, Apr 26 2012
%o A182310 (Haskell)
%o A182310 import Data.Bits (xor)
%o A182310 a182310 n = a182310_list !! n
%o A182310 a182310_list = 0 : map (+ 1)
%o A182310    (zipWith xor a182310_list $ map (`div` 2) a182310_list) :: [Integer]
%o A182310 -- _Reinhard Zumkeller_, Apr 25 2012
%o A182310 (PARI) terms(n) = my(x=0, i=0); while(i < n, print1(x, ", "); x=bitxor(x, floor(x/2)) + 1; i++)
%o A182310 /* Print initial 200 terms as follows: */
%o A182310 terms(200) \\ _Felix Fröhlich_, Jun 29 2021
%Y A182310 Cf. A105081, A182417.
%K A182310 nonn,base
%O A182310 0,3
%A A182310 _Alex Ratushnyak_, Apr 24 2012