Skip to main content
added 91 characters in body
Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80

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;}}

Attempt This Online!Attempt This Online!

C gnu99, 126 116 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.

i=500,d=2,j,t,C[]={[0 ...255]=1};main(){while(i--){putchar(d+48);d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t%j;}}

Attempt This Online!

C, 126 116 109 bytes

Port of my R answer.

-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[255];main(){while(i--){putchar(d+48);d=0;j=254;while(j-->2)t=10*C[j]+d+10,d=t/j,C[j]=t%j-1;}}

Attempt This Online!

added 73 characters in body
Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80

C gnu99, 126126 116 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.

i;d;j;t;C[]=i=500,d=2,j,t,C[]={[0 ...255]=1};main(){putswhile("2"i--);while{putchar(++i<500d+48){d=0;j=254;while;d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t-d*j;putchar(d+48);C[j]=t%j;}}

Attempt This Online!Attempt This Online!

C gnu99, 126 bytes

Port of my R answer. The initialization of array C to 1s is a GNU extension.

i;d;j;t;C[]={[0 ...255]=1};main(){puts("2");while(++i<500){d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t-d*j;putchar(d+48);}}

Attempt This Online!

C gnu99, 126 116 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.

i=500,d=2,j,t,C[]={[0 ...255]=1};main(){while(i--){putchar(d+48);d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t%j;}}

Attempt This Online!

added 58 characters in body
Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80

C gnu99, 126 bytes

Port of my R answer. The initialization of array C to 1s is a GNU extension.

i;d;j;t;C[]={[0 ...255]=1};main(){puts("2");while(++i<500){d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t-d*j;putchar(d+48);}}

Attempt This Online!

C gnu99, 126 bytes

Port of my R answer.

i;d;j;t;C[]={[0 ...255]=1};main(){puts("2");while(++i<500){d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t-d*j;putchar(d+48);}}

Attempt This Online!

C gnu99, 126 bytes

Port of my R answer. The initialization of array C to 1s is a GNU extension.

i;d;j;t;C[]={[0 ...255]=1};main(){puts("2");while(++i<500){d=0;j=254;while(j-->2)t=10*C[j]+d,d=t/j,C[j]=t-d*j;putchar(d+48);}}

Attempt This Online!

Source Link
qwr
  • 12.3k
  • 6
  • 48
  • 80
Loading