![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 for (var m = 1; m <= 9; m++){ 2 for(var n = 1; n <= m; n++){ 3 if (n * m < 10){ 4 document.write(" "); 5 } 6 document.write(n + "*" + m + "="); 7 document.write(n * m + " "); 8 } 9 document.write("<br/>"); 10 }
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 for(var i=1;i<=1000;i++){ 2 if (i % 2!=0) 3 { 4 document.write(i + " "); 5 } 6 } 7 document.write("<br/>")
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 1. for(var i=100;i<999;i++){ 2 var str = '' + i; 3 var a = str.substr(0,1); 4 var b = str.substr(1,1); 5 var c = str.substr(2); 6 var num=(Math.pow(a,3) + Math.pow(b,3) + Math.pow(c,3)); 7 if(num==i){ 8 document.write(i); 9 document.write('<br />'); 10 } 11 } 12 13 2. for(var n=100; n<1000 ;n++){ 14 var a = parseInt(n/100); 15 var b = parseInt((n-a*100)/10); 16 var c = n-a*100-b*10; 17 var s = Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3); 18 if(n==s){ 19 document.write(n+"<br />"); 20 } 21 } 22 23
这是刚开始学习时练习的代码,程序都不难,分享给跟我一样的新手~~