11from algorithms .maths import (
22 int2base , base2int ,
33 extended_gcd ,
4+ factorial , factorial_recur ,
45 gcd , lcm ,
56 gen_strobogrammatic , strobogrammatic_in_range ,
67 is_strobogrammatic , is_strobogrammatic2 ,
@@ -205,7 +206,7 @@ def test_encrypt_decrypt(self):
205206
206207class TestCombination (unittest .TestCase ):
207208 """[summary]
208- Test for the file rsa .py
209+ Test for the file combination .py
209210
210211 Arguments:
211212 unittest {[type]} -- [description]
@@ -215,5 +216,25 @@ def test_combination(self):
215216 self .assertEqual (10 , combination (5 , 2 ))
216217 self .assertEqual (252 , combination (10 , 5 ))
217218
219+ class TestFactorial (unittest .TestCase ):
220+ """[summary]
221+ Test for the file factorial.py
222+
223+ Arguments:
224+ unittest {[type]} -- [description]
225+ """
226+
227+ def test_factorial (self ):
228+ self .assertEqual (1 , factorial (0 ))
229+ self .assertEqual (120 , factorial (5 ))
230+ self .assertEqual (3628800 , factorial (10 ))
231+
232+ def test_factorial_recur (self ):
233+ self .assertEqual (1 , factorial_recur (0 ))
234+ self .assertEqual (120 , factorial_recur (5 ))
235+ self .assertEqual (3628800 , factorial_recur (10 ))
236+
218237if __name__ == "__main__" :
219238 unittest .main ()
239+
240+
0 commit comments