# 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, 2018 at 1:09
• @Jo King No. 1 should refer to the first iteration of the sequence as per the challenge spec. Jul 4, 2018 at 1:14
• 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, 2018 at 1:40
• @Jo King Thanks, I'm glad you liked it. Jul 4, 2018 at 1:41
• Do the outputs have to be in order? Can we mix strings and numbers?
– xnor
Jul 4, 2018 at 2:56

# Shakespeare Programming Language, 310 bytes

,.Ajax,.Ford,.Page,.Act I:.Scene I:.[Enter Ajax and Ford]Ford:Listen tothy.Ajax:You cat.Open heart.[Exit Ajax][Enter Page]Scene V:.Ford:Am I worse Ajax?If notlet usScene X.You be twice the sum ofa cat a big big cat.Speak thy.Page:Open heart.You be the sum ofyou a cat.Open heart.Let usScene V.Scene X:.[Exeunt]


Try it online!

• If you don't mind ending in an error, you can get rid of scene X for 293 bytes
– Jo King
Sep 22, 2018 at 22:01

# Runic Enchantments, 33 bytes

/01iR1-:0)?;{1+:

# RAD, 72 bytes

0,(⊢+10×⊣)⍁¨∊¨(⌽∘⌊(⊢|⍨10*(⍳(1+∘⌊10⍟⊢)))÷10*1-⍨(⍳(1+∘⌊10⍟⊢)))¨¨(⊢,1+⊢)¨⍳⎕


I wanted to try to see if I could do it in a "non-mathematical" way by splitting a number up into its digits.

C, 39 bytes

x(n){n&&x(n-1);printf("%d%d, ",n,n+1);}


eliminated the ternary conditional and shaved off 3 bytes.

• Leaving the main function out is allowed per meta consensus, since it often is shorter than a full program in C submissions often only implement a function. If you want to leave your submission as a whole program, I suggest removing the two spaces in "%d%d, " and char **n. n==0?:x(n-1); can also be n&&x(n-1);. Jul 8, 2018 at 21:30

# ARBLE, 23 20 bytes

Saved a handful of bytes by using better named variables.

range(0,n)//(x..y|0)


Try it online!

# Python 2.7, 52 bytes

I tried my best. Not yet familiar with this golfing thing.

def a(n):
for e in range(n):
print int(e+e+1)


The int() removes the leading zero in the first output, as specified in the rules.

• Changing this to an anonymous lambda function returning a list of numbers gets it down to 42 bytes
– Jo King
Jul 23, 2018 at 1:38