Added function to get factorial of number

This commit is contained in:
2021-06-01 18:31:28 -04:00
parent 61f83228e2
commit a80785e10e

View File

@@ -478,4 +478,13 @@ pub fn gcd(in1: i32, in2: i32) -> i32{
} }
} }
return num1 | num2; return num1 | num2;
}
//Returns the factorial of the number passed in
pub fn factorial(num: i64) -> i64{
let mut fact = 1;
for cnt in 1 ..= num{
fact *= cnt;
}
return fact;
} }