Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
|
|
@ -2,11 +2,11 @@ function factorial(n) {
|
|||
//check our edge case
|
||||
if (n < 0) { throw "Number must be non-negative"; }
|
||||
|
||||
var sum = 1;
|
||||
var result = 1;
|
||||
//we skip zero and one since both are 1 and are identity
|
||||
while (n > 1) {
|
||||
sum *= n;
|
||||
result *= n;
|
||||
n--;
|
||||
}
|
||||
return sum;
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue