1. 程式人生 > >7.22擴展題

7.22擴展題

for 次方 type 輸出 javascrip 一個 document 結果 現在

第一題:
X3 * 6528 = 3X * 8256
X為一個數字 填入一個數字 使等式成立

第二題:
在頁面上輸出以下圖形
*
***
*****
*******
*********

第三題:
找出100-999之間的所有“水仙花數”。所謂水仙花數是指一個三位 數,各位數字的立方和等於該數本身。(如15的3次方=1的3次方+5的3次方+3的3次方)並輸出這些數字

第四題:
輸出1000年到現在的所有閏年

第五題:
編寫程序,計算 1!+2!+3!+…..+10!的結果。

1:

<script>
for(x=1;x<10;x++){
var a=10*x+3
var b=3*10+x
if(a*6528==b*8256){
alert(x)
}
}
</script>

2:

<script>
(1) a="*"
for(i=1;i<6;i++){
for(y=1;y<6-i;y++){
document.write("&nbsp","&nbsp")
}
for(x=1;x<2*i;x++){
document.write(a)
}
document.write("<br />")
}

(2) a="*" for(i=1;i<6;i++){
for(y=4;y>i-5;y--){
document.write("&nbsp","&nbsp")
}
for(x=1;x<2*i;x++){
document.write(a)
}
document.write("<br />")
}
</script>
3:

<script>
for(x=1;x<10;x++){
for(y=0;y<10;y++){
for(z=0;z<10;z++){
a=x*x*x+y*y*y+z*z*z
b=100*x+10*y+z
if(a==b&&b>=100&&b<=999){
document.write(x+""+y+""+z+"<br />")
}
}
}
}
</script>
4:

<script>
for(x=1000;x<2018;x++){
if(x%4==0&&x%100!==0||x%400==0){
document.write(x+",")
}
}
</script>
5:

<script type="text/javascript">
c=0
for(i=1;i<11;i++){
b=1
for(a=1;a<i+1;a++){
b *=a

}
c +=b
}
document.write(c)
</script>

7.22擴展題