login
Concatenate the decimal numbers n n-2 n-4 ...5 3 1 2 4 ... n-5 n-3 n-1 if n is odd, or n n-2 n-4 ... 6 4 2 1 3 5 ... n-5 n-3 n-1 if n is even.
3

%I #26 Jan 16 2020 13:33:35

%S 1,21,312,4213,53124,642135,7531246,86421357,975312468,10864213579,

%T 1197531246810,121086421357911,13119753124681012,1412108642135791113,

%U 151311975312468101214,16141210864213579111315,1715131197531246810121416

%N Concatenate the decimal numbers n n-2 n-4 ...5 3 1 2 4 ... n-5 n-3 n-1 if n is odd, or n n-2 n-4 ... 6 4 2 1 3 5 ... n-5 n-3 n-1 if n is even.

%C The old name was "Alternately concatenate the decimal digits from back to front 1...n such that n is always to the left.".

%C a(40714), with 192464 decimal digits, is the sequence's first (probable) prime. - _Hans Havermann_, Dec 17 2019

%C The terms at even indices are the same as the even-indexed terms of A053063. - _Hans Havermann_, Jan 16 2020

%H Indranil Ghosh, <a href="/A281254/b281254.txt">Table of n, a(n) for n = 1..340</a>

%e a(13) = 13119753124681012.

%p b:= proc(n) b(n):= `if`(n=1, 1, parse(cat(a(n-1), n))) end:

%p a:= proc(n) a(n):= `if`(n=1, 1, parse(cat(n, b(n-1)))) end:

%p seq(a(n), n=1..20); # _Alois P. Heinz_, Jan 18 2017

%t f[n_] := Fold[ If[ Mod[n +#2, 2] == 0, #2, #1]*10^IntegerLength@ If[ Mod[n +#2, 2] == 0, #1, #2] +If[ Mod[n +#2, 2] == 1, #2, #1] &, 0, Range@ n]; Array[f, 17]

%o (Python)

%o def a(n):

%o ....if n==1:

%o ........return ["1"]

%o ....return [str(n)]+a(n-1)[::-1]

%o def A281254(n):

%o ....return "".join(a(n)) # _Indranil Ghosh_, Jan 23 2017

%Y See A053063 for another version.

%Y Cf. A000422, A007908, A138793, A138957, A281253.

%K nonn,base

%O 1,2

%A _Robert G. Wilson v_, Jan 18 2017

%E Edited by _N. J. A. Sloane_, Dec 07 2019