def testIterativeEnormousSucceeds(self):
     factorial.iterative(sys.getrecursionlimit() + 1)
Esempio n. 2
0
#!/usr/bin/env python3

'''
output factorial of a number
'''

from __future__ import print_function

__copyright__ = 'Copyright 2015 Holiday Extras'
__licence__ = 'GPL'

import sys
import factorial

# if we didn't get exactly 2 arguments on the command line
# (the first one is the script name)
if len( sys.argv ) != 2:
  print( 'usage:', sys.argv[0], '[a number]' )
  exit( )

print( factorial.recursive( int( sys.argv[1] )))
print( factorial.iterative( int( sys.argv[1] )))
 def testFromArrayIterative(self):
     for datum in _data:
         self.assertEqual(factorial.iterative(datum[0]), datum[1])
 def testIterativeEnormousSucceeds(self):
     factorial.iterative(sys.getrecursionlimit() + 1)
 def testFromArrayIterative(self):
     for datum in _data:
         self.assertEqual(factorial.iterative(datum[0]), datum[1])
Esempio n. 6
0
 def test_iterative_number_we_know( self ):
   self.assertEqual( 5040, iterative( 7 ));
Esempio n. 7
0
 def test_iterative_zero( self ):
   # if we'd just done "import factorial"
   # self.assertEqual( 1, factorial.iterative( 0 ));
   # but we imported just the function iterative so we can do:
   self.assertEqual( 1, iterative( 0 ));