daily pastebin goal
72%
SHARE
TWEET

Untitled

a guest Jan 16th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top