mirror of
https://bitbucket.org/Mattrixwv/rustclasses.git
synced 2025-12-06 18:34:00 -05:00
Added function to get factorial of number
This commit is contained in:
@@ -479,3 +479,12 @@ 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user