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

R is not a simple programming language, and it does better on reading excel files than python

R is not a simple programming language, and it does better on reading excel files than python . tried to read excel files to python and R. i...