project: factorials
Write a script with a function called calculate_factorial
that takes a number and returns its factorial.
In a separate file, write some tests that prove that your code works.
Javascript instructions
- Name your script
factorial.js
- Use
jasmine
to test your code
Python instructions
- Name your script
factorial.py
- Use
pytest
to test your code
Steps:
- Think about which tests you want to do to test that the factorial function works.
- Write the tests first (before creating the function).
- Test an empty function called factorial - it should fail the tests
- Add code for returning the factorial of a number - it should pass for numbers >= 1
- Add code for dealing with zero - should pass unit test for zero and for numbers >= 1
- Add code for dealing with negative numbers
- Add code for dealing with non-numeric input
Make sure you use Github to keep track of your progress.
References:
Factorial Numbers