【问题标题】:what is wrong with this code? it is not giving any output这段代码有什么问题?它没有给出任何输出
【发布时间】:2022-06-13 23:01:39
【问题描述】:
n = int(input("Enter your number:\n"))
def factorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return (n* factorial(n-1))

我应该在哪里使用打印功能来获得期望的输出。应该在阶乘函数中使用还是在 if else 函数中使用?

【问题讨论】:

  • 你曾经调用过这个函数吗?

标签: python function if-statement recursion factorial


猜你喜欢
  • 1970-01-01
  • 2021-09-06
  • 1970-01-01
  • 2021-11-13
  • 2021-02-24
  • 2020-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多