%I #11 Mar 13 2014 16:36:16
%S 0,1,4,2,7,3,10,5,16,8,25,6,19,9,28,12,37,18,55,11,34,17,52,13,40,20,
%T 61,14,43,21,64,32,97,24,73,36,109,22,67,33,100,50,151,23,70,35,106,
%U 26,79,15,46,139,69,208,80,241,30,91,27,82,41,124,31,94,47,142,71,214,53,160
%N a(n+1) = if it exists, smallest number not occurring earlier that is contained in binary representation of a(n), otherwise: a(n+1) = 3*a(n)+1; a(0) = 0.
%C Permutation of the natural numbers with inverse A180077;
%C if a(n-1) > a(n) then a(n) < a(n+1) = 3*a(n)+1;
%C see A180110 for m with a(m-2) < a(m-1) < a(m);
%C A180078(n) = a(a(n));
%C a(A180079(n)) = A180079(a(n)) = A180077(n);
%C A180080 and A180081 give record values and where they occur.
%H Reinhard Zumkeller, <a href="/A180076/b180076.txt">Table of n, a(n) for n = 0..10000</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%o (Haskell)
%o import Data.List (delete)
%o a180076 n = a180076_list !! n
%o a180076_list :: [Integer]
%o a180076_list = 0 : f 0 [1..] where
%o f x zs = y : f y (delete y zs) where
%o y = if null ys then 3 * x + 1 else head ys
%o ys = [y | y <- takeWhile (< x) zs, binInfix y x]
%o binInfix u v = ib v where
%o ib w = w `mod` m == u || w > u && ib (w `div` 2)
%o m = a062383 u
%o -- _Reinhard Zumkeller_, Mar 13 2014, Feb 19 2013
%Y Cf. A007088, A016777.
%Y Cf. A030308.
%Y Cf. A062383.
%K base,nonn
%O 0,3
%A _Reinhard Zumkeller_, Aug 14 2010
|