diff --git a/printNumbers/__pycache__/docopt.cpython-39.pyc b/printNumbers/__pycache__/docopt.cpython-39.pyc
new file mode 100644
index 0000000..2fadf1f
Binary files /dev/null and b/printNumbers/__pycache__/docopt.cpython-39.pyc differ
diff --git a/printNumbers/__pycache__/parameters.cpython-39.pyc b/printNumbers/__pycache__/parameters.cpython-39.pyc
new file mode 100644
index 0000000..4da45b2
Binary files /dev/null and b/printNumbers/__pycache__/parameters.cpython-39.pyc differ
diff --git a/printNumbers/functions/__pycache__/__init__.cpython-39.pyc b/printNumbers/functions/__pycache__/__init__.cpython-39.pyc
new file mode 100644
index 0000000..86e69e3
Binary files /dev/null and b/printNumbers/functions/__pycache__/__init__.cpython-39.pyc differ
diff --git a/printNumbers/functions/__pycache__/factorial.cpython-39.pyc b/printNumbers/functions/__pycache__/factorial.cpython-39.pyc
new file mode 100644
index 0000000..75f6f6a
Binary files /dev/null and b/printNumbers/functions/__pycache__/factorial.cpython-39.pyc differ
diff --git a/printNumbers/functions/__pycache__/fibonacci.cpython-39.pyc b/printNumbers/functions/__pycache__/fibonacci.cpython-39.pyc
new file mode 100644
index 0000000..d319a74
Binary files /dev/null and b/printNumbers/functions/__pycache__/fibonacci.cpython-39.pyc differ
diff --git a/printNumbers/functions/__pycache__/gamma.cpython-39.pyc b/printNumbers/functions/__pycache__/gamma.cpython-39.pyc
new file mode 100644
index 0000000..47fe1a2
Binary files /dev/null and b/printNumbers/functions/__pycache__/gamma.cpython-39.pyc differ
diff --git a/printNumbers/functions/gamma.py b/printNumbers/functions/gamma.py
new file mode 100755
index 0000000..5b96a62
--- /dev/null
+++ b/printNumbers/functions/gamma.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+#
+# gamma.py
+#
+# This file is part of printNumbers.
+#
+# Copyright (C) 2017 G. Trensch, Simulation & Datalab Neuroscience, JSC, FZ Juelich
+#
+# printNumbers is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# printNumbers is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with printNumbers. If not, see .
+
+import math
+
+def Gamma(n):
+ '''
+ :param n: Operand
+ :return: Gamma(n)=(n-1)!
+ '''
+ return(math.gamma(n))
+
+#To check if the comment shows up later
diff --git a/printNumbers/parameters.py b/printNumbers/parameters.py
index aebe0c3..14e483f 100755
--- a/printNumbers/parameters.py
+++ b/printNumbers/parameters.py
@@ -26,9 +26,10 @@
CONST_VERSION = 'V1.0'
CONST_VERSION_STRING = '+ + PrintNumbers ' + CONST_VERSION + ' (Software Development in Science) + +'
CONST_DEF_OPERAND_VAL = 10
-CONST_MAX_OPERAND_VAL = 20
+CONST_MAX_OPERAND_VAL = 22
CONST_FUNC_CODE_FIBONACCI = 0
CONST_FUNC_CODE_FACTORIAL = 1
+CONST_FUNC_CODE_GAMMA = 2
class Parameters(object):
@@ -43,6 +44,8 @@ def __setParameters(self, cmdLineArgs):
self.functionIndex = CONST_FUNC_CODE_FIBONACCI
elif cmdLineArgs['--factorial']:
self.functionIndex = CONST_FUNC_CODE_FACTORIAL
+ elif cmdLineArgs['--gamma']:
+ self.functionIndex = CONST_FUNC_CODE_GAMMA
@property
def operand(self):
diff --git a/printNumbers/printNumbers.py b/printNumbers/printNumbers.py
index 9f9ef0e..d3de595 100755
--- a/printNumbers/printNumbers.py
+++ b/printNumbers/printNumbers.py
@@ -27,24 +27,27 @@
"""
Usage:
printNumbers.py -h --help
- printNumbers.py [--fibonacci|--factorial]
+ printNumbers.py [--fibonacci|--factorial|--gamma]
Options:
-h --help Print usage.
--fibonacci Print the fibonacci sequence.
--factorial Print the factorial.
+ --gamma Print the Gamma function.
"""
from docopt import docopt
from parameters import *
from functions.fibonacci import *
from functions.factorial import *
+from functions.gamma import *
#
# FUNCTION TABLE
#
functionTable = { CONST_FUNC_CODE_FIBONACCI : FibonacciSequence,
CONST_FUNC_CODE_FACTORIAL : Factorial,
+ CONST_FUNC_CODE_GAMMA : Gamma
}
#
@@ -67,3 +70,5 @@
print('fib(' + str(params.operand) + ') =', result)
elif params.functionIndex == CONST_FUNC_CODE_FACTORIAL:
print(str(params.operand) + '! =', str(result))
+ elif params.functionIndex == CONST_FUNC_CODE_GAMMA:
+ print('Gamma(' + str(params.operand) + ') = ', result)
diff --git a/printNumbers/unittests/test_factorial.py b/printNumbers/unittests/test_factorial.py
index 61ff579..0bbdfc2 100755
--- a/printNumbers/unittests/test_factorial.py
+++ b/printNumbers/unittests/test_factorial.py
@@ -42,7 +42,9 @@ def test_value_2(self):
def test_value_20(self):
self.assertEqual(Factorial(20), 2432902008176640000)
-
+
+ def test_jane(self):
+ self.assertEqual(Factorial(5),3)
def suite():
suite = unittest.makeSuite(TestFactorial, 'test')
@@ -54,3 +56,4 @@ def run():
if __name__ == "__main__":
run()
+
diff --git a/printNumbers/unittests/test_gamma.py b/printNumbers/unittests/test_gamma.py
new file mode 100755
index 0000000..f8423d0
--- /dev/null
+++ b/printNumbers/unittests/test_gamma.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+#
+# test_gamma.py
+#
+# This file is part of PrintNumbers.
+#
+# Copyright (C) 2017 G. Trensch, Simulation & Datalab Neuroscience, JSC, FZ Juelich
+#
+# PrintNumbers is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# PrintNumbers is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with PrintNumbers. If not, see .
+
+#
+# Unit tests: 'gamma'.
+#
+
+import sys, os
+sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+
+import unittest
+from functions.gamma import *
+
+class TestGamma(unittest.TestCase):
+
+ def test_value_1(self):
+ self.assertEqual(Gamma(1), 1)
+
+ def test_value_2(self):
+ self.assertEqual(Gamma(2), 1)
+
+ def test_value_21(self):
+ self.assertEqual(Gamma(21), 2432902008176640000)
+
+
+def suite():
+ suite = unittest.makeSuite(TestGamma, 'test')
+ return suite
+
+def run():
+ runner = unittest.TextTestRunner(verbosity = 2)
+ runner.run(suite())
+
+if __name__ == "__main__":
+ run()