Guest User

Untitled

a guest
Jan 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. fn main() {
  2. println!("Hello, world! {}", factorial(8));
  3. }
  4.  
  5. fn factorial<T: num::One + std::ops::Mul + std::ops::Sub<Output = T> + PartialEq + Copy>(
  6. a: T,
  7. ) -> T {
  8. if a == T::one() {
  9. a
  10. } else {
  11. a * factorial(a - T::one())
  12. }
  13. }
Add Comment
Please, Sign In to add comment