Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- println!("Hello, world! {}", factorial(8));
- }
- fn factorial<T: num::One + std::ops::Mul + std::ops::Sub<Output = T> + PartialEq + Copy>(
- a: T,
- ) -> T {
- if a == T::one() {
- a
- } else {
- a * factorial(a - T::one())
- }
- }
Add Comment
Please, Sign In to add comment