Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from abc import ABC, abstractclassmethod
- class Calculator(ABC):
- @abstractclassmethod
- def compute(self):
- pass
- class Factorial( Calculator ):
- def compute(self,n):
- num = 1
- while n >= 1:
- num = num * n
- n = n - 1
- return num
- n = float(input("Enter n "))
- f = Factorial()
- print( "n! =", f.compute( n ) )
- print( "n!! =", f.compute( f.compute( n ) ) )
Advertisement
Add Comment
Please, Sign In to add comment