login
a(1)=1; a(n) = smallest positive integer not yet in the sequence, such that a(n) and a(n-1) have exactly one common 1-bit in their binary representations.
6

%I #8 May 26 2013 21:57:00

%S 1,3,2,6,4,5,9,7,10,8,11,12,20,13,17,15,18,14,19,16,21,24,22,25,33,23,

%T 34,26,35,29,36,28,37,27,38,32,39,40,30,41,48,31,65,43,52,42,49,44,50,

%U 45,67,46,66,47,68,53,70,51,69,54,74,55,73,56,72,57,71,58,76,59,80,60,75,64,77,82,61,96,62,81,78,97,84,98,85,104,83,100,88

%N a(1)=1; a(n) = smallest positive integer not yet in the sequence, such that a(n) and a(n-1) have exactly one common 1-bit in their binary representations.

%C A000120(a(n) & a(n+1))=1, where & stands for the bitwise AND operator.

%C Permutation of the natural numbers with inverse A226093. - _Reinhard Zumkeller_, May 26 2013

%H Paul Tek, <a href="/A226077/b226077.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%e a(1)=1 by definition.

%e A000120(a(1) & 2)=0, A000120(a(1) & 3)=1, hence a(2)=3.

%e A000120(a(2) & 2)=1, hence a(3)=2.

%e A000120(a(3) & 4)=0, A000120(a(3) & 5)=0, A000120(a(3) & 6)=1, hence a(4)=6.

%e A000120(a(4) & 4)=1, hence a(5)=4.

%e A000120(a(5) & 5)=1, hence a(6)=5.

%e A000120(a(6) & 7)=2, A000120(a(6) & 8)=0, A000120(a(6) & 9)=1, hence a(7)=9.

%e A000120(a(7) & 7)=1, hence a(8)=7.

%e A000120(a(8) & 8)=0, A000120(a(8) & 10)=1, hence a(9)=10.

%e A000120(a(9) & 8)=1, hence a(10)=8.

%o (Haskell)

%o import Data.Bits ((.&.))

%o import Data.List (delete)

%o a226077 n = a226077_list !! (n-1)

%o a226077_list = 1 : f 1 [2..] where

%o f :: Integer -> [Integer] -> [Integer]

%o f x zs = g zs where

%o g (y:ys) | a209229 (x .&. y) == 0 = g ys

%o | otherwise = y : f y (delete y zs)

%o -- _Reinhard Zumkeller_, May 26 2013

%Y Cf. A109812, A115510, A000120.

%Y Cf. A209229.

%K nonn,base

%O 1,2

%A _Paul Tek_, May 25 2013