login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A238704
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
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, 35, 37, 39, 41, 20, 22, 24, 26, 28, 30, 43, 32, 45, 34, 47, 36, 49, 38, 51, 53, 55, 57, 59, 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
OFFSET
1,2
COMMENTS
This is a permutation of the natural numbers > 0.
PROG
(Haskell)
import Data.List (delete)
a238704 n = a238704_list !! (n-1)
a238704_list = 1 : f 1 [2..] where
f x zs = g zs where
g (y:ys) =
if y `mod` 2 /= m then g ys else y : f y (delete y zs)
m = a000030 x `mod` 2
-- Reinhard Zumkeller, Mar 03 2014
CROSSREFS
Cf. A000030, A238718 (inverse).
Sequence in context: A329835 A356929 A187349 * A338742 A251238 A059547
KEYWORD
nonn,base,look
AUTHOR
Eric Angelini, Mar 03 2014
STATUS
approved