ezoic

Thursday, March 2, 2017

Python problem 2

Write a program which can compute the factorial of a given numbers.
The results should be printed in a comma-separated sequence on a single line.
Suppose the following input is supplied to the program


class Solution:
   def fac1( self,num):
        if num==0:
            return(1)
        else:
            return(num*self.fac1(num-1))




if __name__=="__main__":
    kk=Solution()
    print(kk.fac1(5))

if you do not put self  before fac1 in else, it will have an error.




No comments:

Post a Comment

looking for a man

 I am a mid aged woman. I live in southern california.  I was born in 1980. I do not have any kid. no compliacted dating.  I am looking for ...