Skip to main content
2 of 12
Added test cases.
devRicher
  • 1.7k
  • 13
  • 36

Output integers in negative order, increase the maximum integer everytime

Main task

Your task is to print out integers in descending order, starting from 1, and increasing as you keep hitting 1 again, up until the given input is reached, then, print out the rest until you hit 1 again. Example with input 6:

1
21
321
4321
54321
654321
Without newlines:
121321432154321654321

Side note: this is A004736 in the OEIS. Input

Your code may take any kind of input (graphical, STDIN) in the form of an integer or number. Output

Your code should output the above described sequence, up until the input number is reached, then finish to output until it reaches 1 again. The output may be anything, therefore arrays, numbers, strings, integers, or graphical output. It is required to print out a single number (no newlines if it's a string).

Rules

  • The output must be a full number, not split up by anything, not even newlines.

Test cases

Input: 6
Output: 121321432154321654321

Input: 1
Output: 1

Input: 26
Output: 121321432154321654321765432187654321987654321109876543211110987654321121110987654321131211109876543211413121110987654321151413121110987654321161514131211109876543211716151413121110987654321181716151413121110987654321191817161514131211109876543212019181716151413121110987654321212019181716151413121110987654321222120191817161514131211109876543212322212019181716151413121110987654321242322212019181716151413121110987654321252423222120191817161514131211109876543212625242322212019181716151413121110987654321

Input: 0
Output: 0, Empty, or Error

Thanks @Emigna, I used his algorithm to calculate these test cases. Winner

This is , so the answer with the least bytes wins!

devRicher
  • 1.7k
  • 13
  • 36