/**
*
* Ashish Patel
* e: ashishsushilPatel@gmail.com
* w: https://ashish.me
*
*/
/*
Return the factorial of the provided integer.
If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.
Factorials are often represented with the shorthand notation n!
For example: 5! = 1 * 2 * 3 * 4 * 5 = 120
*/
function factorializeANumber(value) {
if(value === 1){
return 1
}
return value * factorializeANumber(value-1)
}
test('factorialize A Number', () => {
expect(factorializeANumber(5)).toEqual(120)
});
Created 2019-12-14T23:23:16+05:30 · Edit