代码示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> function jiecheng(a){ var b =1 for(;a>=1;a--){ b *=a } return b } var c = jiecheng(10) console.log(c) var d = jiecheng(12) document.write(d) </script> </body> </html>
代码示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> function shulie(n){ if(n===1 || n===2) return 1 return shulie(n-1)+shulie(n-2) } var a=shulie(9) console.log(a) </script> </body> </html>