Let's define a sequence of positive integers. We will define the sequence on even numbers to be double the previous term. The odd indices of the sequence will be smallest positive integer not yet appearing in the sequence.
Here are the first couple terms.
1,2,3,6,4,8,5,10,7,14,9,18,11,22,12,24,13,26,15,30
You can also think of this as the list of concatenated pairs (n,2n) where n is the least unused positive integer so far.
Task
Given a number n as input calculate the nth term in this sequence.
This is code-golf so you should aim to minimize the size of your source code as measured in bytes.
(n,2n)
and each number appears only once. Each pair is chosen to be the smallest possible while adhering to the latter constraint. \$\endgroup\$ – Martin Ender Jul 12 '17 at 14:56