This javascript code:
for(x=1;x<6;x++)for(y=1;y<6;y++)console.log((y==1?'\n':'')+x+'*'+y+'='+x*y);
prints the following:
1*1=1
1*2=2
1*3=3
1*4=4
1*5=5
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25
2 questions:
- Is there a smaller (in bytes) way to do the same?
- What is the smallest code that can do the same without using 2
for
statements?
1
s, two blocks of3
s, and no block of2
s or4
s? I don't think that's what the code outputs... \$\endgroup\$