login
a(1)=1; the sequence S is always extended with the smallest integer not yet present in S that has the same parity as the first digit of the previous term.
2

%I #21 Jun 10 2016 00:21:00

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

%T 35,37,39,41,20,22,24,26,28,30,43,32,45,34,47,36,49,38,51,53,55,57,59,

%U 61,40,42,44,46,48,50,63,52,65,54,67,56,69,58,71,73,75,77,79,81,60,62,64,66,68,70,83,72,85,74,87,76,89,78,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125

%N a(1)=1; the sequence S is always extended with the smallest integer not yet present in S that has the same parity as the first digit of the previous term.

%C This is a permutation of the natural numbers > 0.

%H Reinhard Zumkeller, <a href="/A238704/b238704.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Angelini, <a href="http://www.cetteadressecomportecinquantesignes.com/ParityFirstDigit.htm">Parity given by first digit of the previous term</a>

%H E. Angelini, <a href="/A238704/a238704.pdf">Parity given by first digit of the previous term</a> [Cached copy, with permission]

%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 a238704 n = a238704_list !! (n-1)

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

%o f x zs = g zs where

%o g (y:ys) =

%o if y `mod` 2 /= m then g ys else y : f y (delete y zs)

%o m = a000030 x `mod` 2

%o -- _Reinhard Zumkeller_, Mar 03 2014

%Y Cf. A000030, A238718 (inverse).

%K nonn,base,look

%O 1,2

%A _Eric Angelini_, Mar 03 2014