# Concatenating n with n + 1

## Introduction

OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are:

1, 12, 23, 34, 45, 56, 67, 78, 89, 910, 1011, 1112, 1213, 1314, 1415, 1516, 1617, 1718, 1819, 1920, 2021, 2122, 2223, 2324, 2425, 2526, 2627, 2728, 2829, 2930, 3031, 3132, 3233, 3334, 3435, 3536, 3637, 3738, 3839, 3940, 4041, 4142, 4243, 4344, 4445, 4546, …

## Challenge

Given a single positive integer n, print the first n entries of OEIS sequence A127421 in increasing order.

• Input and output can be in any acceptable format. Strings or numbers are fine for output.
• Leading zeroes are not permitted.
• Either a full program or function is permitted.
• For the purposes of this challenge, n will be positive and under 100.
• Standard loopholes are disallowed by default.
• This question is code golf, so lowest byte-count wins.
• Here is some sample input and output:

1 => 1
2 => 1, 12
3 => 1, 12, 23
10 => 1, 12, 23, 34, 45, 56, 67, 78, 89, 910


If you have any questions, don't hesitate to ask. Good luck.

P.S this is my first challenge, so hopefully this all makes sense.

EDIT: Removed output restriction to allow numbers or strings.

• Can it be 0 indexed? – Jo King Jul 4 '18 at 1:09
• No-one's said it yet, but welcome to PPCG! Nice first question, not too hard, yet not completely trivial either, and there's a number of different approaches – Jo King Jul 4 '18 at 1:40
• After 7 days, I will accept the shortest answer which meets all these criteria. Why is there a need for the challenge to end? – Erik the Outgolfer Jul 4 '18 at 9:13
• Nowadays we tend to not accept an answer, because it discourages further posting of answers. I suppose you take old challenges as a model (which is also discouraged) See things-to-avoid-when-writing-challenges – user202729 Jul 4 '18 at 9:21
• @Dennis Ok, i'll remove the date from the challenge; maybe I'll accept when no more new answers are coming. – Amphibological Jul 4 '18 at 13:41

# Python 2, 42 bytes

a=0
exec"printa[:a]+a+1;a+=1;"*input()


Try it online!

# Pepe, 68 bytes

RrEEEEEREeErREEREEEEEREErEEEEEeEErEEEereEEreeErEEEEEeeEReerREEREeRee


Try it online!

Previous code has errors when giving input 0, so this is fixed!

Explanation:

# Preparation

RrEEEEE # Stack r: [0, 1]

REeE # Stack R: [input]

# Loop

rREE # create label input (r flag: skip until REe)

REEEEE # increment input (loop preparation)
REE # create label input

rEEEEEeEE # join all
rEEEe # move r pointer to last
reEE # output as int
reeE # output newline "\n"
rEEEEEeeE # increment all

Ree # repeat if input != last content of stack
rREE # create label input + 1 (r flag: skip until REe)
REe # stop skipping commands

Ree # if not 0, go to loop


# Kotlin, 43 bytes

Lambda takes an Int and returns a List<Int> representing the sequence.

{(1..it).mapIndexed{i,v->(""+i+v).toInt()}}


## Explanation

{                                                   // lambda (Int) -> List<Int>
(1..it)                                         // range from 1 to input
.mapIndexed { i, v ->                    // map over "i"ndex and "v"alue
(""+i+v)           // coerce to string and concat
.toInt()}  // convert to int


Try it online!

# Microscript II, 16 bytes

1vsN-s{lPps1+v}*


Output is newline-separated.

# Gol><>, 11 bytes

IFLL?nLPN|;


Try it online!

Explanation:

IFLL?nLPN|;

I           //Take a number as input
F          //Loop as many times as the input specified
LL        //  Push the loop counter twice to the stack (same as L:)
?n      //  Check wether the count is zero, if not print the counter as the first digit
LP    //  Push the loop counter and add 1
N   //  Output the next digits of the number with nl
|; //Exit code


# jq, 30 characters

range(.)|"\(.)\(.+1)"|tonumber


Sample run:

bash-4.4$jq 'range(.)|"\(.)\(.+1)"|tonumber' <<< 5 1 12 23 34 45  Try it online! # Dart, 46 45 bytes f(n)=>List.generate(n,(e)=>e<1?1:'$e\${e+1}');


• -1 byte by replacing e==0 by e<1
• Try it online!