1 function fact(n)
 2     if 1 == n then
 3         return 1
 4     else
 5         return n * fact(n-1)
 6     end
 7 end
 8 
 9 print("Enter a number : ")
10 a = io.read("*number")        
11 print(fact(a))

注意第 10 行的写法。

相关文章:

  • 2021-04-05
  • 2021-11-19
  • 2021-10-27
  • 2022-12-23
  • 2021-03-31
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
相关资源
相似解决方案