Golomb's sequence to 1000000 This used to be an old Computer Olympiad Question, not sure what the actual source was.

Assume function f:


f(1) = 1
This f(1), f(2), f(3), f(4), ... sequence of numbers are in ascending order.
Number n has been repeated f(n) times


Here is the sequence up to the fifteenth number:

n :     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
f(n) :  1 2 2 3 3 4 4 4 5  5  5  6  6  6  6


for example number 4 has been repeated f(4) = 3 times.

So what you should do is to print out the sequence till f(1000000). There are no inputs.

Also you can run out of memory, not an issue! Code with less bytes wins.

So this is how to output will look like:
1 2 2 3 3 4 4 4 5 ...
CJam (22 bytes)

1{_~$(~$-)~$)}A6#(/]S*


Online demo for only 15 terms

This relies on one of the formulae given in the entry for OEIS A001462, and the use of ~$ to index the stack from the bottom.