7
Definition
Define the nth term of the CRAU sequence as follows.
Begin with the singleton array A = [n].
Do the following n times:
For each integer k in A, replace the entry k with k natural numbers, counting from 1 to k.
Compute the sum of all integers in A.
For example, if n = 3, we start with the list [3].
We replace 3 with 1, 2, 3, yielding [1, 2, 3].
We now replace 1, 2, and 3 with 1, 1, 2 and 1, 2, 3 (resp.), yielding [1, 1, 2, 1, 2, 3].
Finally, we perform the same replacements as in the previous step for all six integers in the array, yielding [1, 1, 1, 2, 1, 1, 2, 1, 2, 3].
The sum of the resulting integers is 15, so this is the third CRAU number.
Task
Write a program of a function that, given a strictly positive integer n as input, computes the nth term of the CRAU sequence.
This is code-golf. May the shortest code in bytes win!
Test cases
1 -> 1
2 -> 4
3 -> 15
4 -> 56
5 -> 210
6 -> 792
7 -> 3003
8 -> 11440
9 -> 43758
10 -> 167960
11 -> 646646
12 -> 2496144
13 -> 9657700
Is there a limit on the maximum number the program can handle? i.e. is it acceptable if my program returns a stack overflow for 13? – Fatalize – 2016-06-21T07:07:58.270
As long as your algorithm works for arbitrarily large numbers, your implementation may error if the input is too big. – Dennis – 2016-06-21T07:13:08.753
2This seems a rather roundabout way to present a challenge to compute
choose(2*n,n-1)
. – xnor – 2016-06-21T07:27:58.5572
@xnor http://chat.stackexchange.com/transcript/message/30500547#30500547
– Dennis – 2016-06-21T07:29:30.0301I'm calling it a dupe of a previous (disguised) binomial challenge. Maybe you can instead have the output be the full list without summing? – xnor – 2016-06-21T07:33:46.560
5
Welcome to Programming Puzzles and Code Golf! Unfortunately this challenge is too similar to Code Golf: Number of paths! to warrant a separate post. I recommend posting future challenges to the Sandbox where they can get meaningful feedback before being posted to the main site. ;-P
– Digital Trauma – 2016-06-21T19:24:33.1073@DigitalTrauma Thank you. I'll keep that in mind. – Dennis – 2016-06-21T22:20:00.897