C gnu99, 126 116116 109 bytes
Port of my R answer. The initialization of array C
to 1s is a GNU extension.
-10 bytes by rearranging loop logic printing leading 2, inspired by pajonk, and some small optimizations.
-7 bytes by using C
with zeros instead of ones, credit
chux - Reinstate Monica. Previously, the initialization of array C
to 1s is a GNU extension.
i=500,d=2,j,t,C[]={[0 ...255]=1};mainC[255];main(){while(i--){putchar(d+48);d=0;j=254;while(j-->2)t=10*C[j]+dt=10*C[j]+d+10,d=t/j,C[j]=t%j;C[j]=t%j-1;}}