I wrote a code that separates the numbers from 1 to 9999 by comma
void p(n){printf("%d,",n);if(n<9999){p(n+1);}}main(){p(1);}
Is there a way to make this short code without using a repeat statement?
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this communityI wrote a code that separates the numbers from 1 to 9999 by comma
void p(n){printf("%d,",n);if(n<9999){p(n+1);}}main(){p(1);}
Is there a way to make this short code without using a repeat statement?
i;main(){main(dprintf(i++<9999,"%d,"));}
i;main(){++i<1e4&&main(printf("%d,",i));}
main(i){i<1e4&&main(i+1,printf("%d,",i));}
main
can be used to recurse
n;main(){++n<1e4&&main(printf("%d,",n));}
\$\endgroup\$
Oct 24 at 6:33
main(i){for(;i<1e4;)printf("%d,",i++);}
\$\endgroup\$
Oct 24 at 19:10
without using a repeat statement?
\$\endgroup\$
i;main(){main(dprintf(i++<9999,"%d,"));}
\$\endgroup\$
print(*range(1,10000),sep=',')
print(str(list(range(10000)))[4:-1])
i=0
while i<1e5:print(end='%d,'%i);i+=1
print(",".join(map(str,range(1,10000))))
Console.WriteLine(string.Join(",",Enumerable.Range(1, 999).ToList()));
Saved 14 bytes thanks to Jupotters comment
Console.Write(string.Join(",",Enumerable.Range(1,9999)));
Console.Write(string.Join(",",Enumerable.Range(1,9999)));
\$\endgroup\$
main=putStr.init.tail$show[1..9999]
main=putStr.init.tail.show$[1..9999]
Range@9999~StringRiffle~","
Range@9999
(10 bytes) almost does it...