Python的新手尝试了所有我认为需要解决的简单解决方案,以帮助Plz?
当数字等于零时,它可以正常工作。
class First: #create Class
def __init__(self,number): #constructor
self.number=number
def factorial(reference,number): #Problem within this Code
if reference.number==0:
return 1
else:
return (reference.number*reference.factorial(reference.number-1))
object1 = First(0) #object creation
object1.number=int(input(["Enter The number For Factorial"]))
print("Factorial of a No is::",object1.factorial(object1.number))
如果reference.number == 0:>
RecursionError:在比较中超过了最大递归深度