Last active
November 26, 2024 12:41
-
-
Save masiarek/3de96d0ec14d83f28e0b8b4740aa7ced to your computer and use it in GitHub Desktop.
both work OK (compilation and cargo test)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() {} | |
fn factorial(n: u64) -> u64 { | |
if n == 0 || n == 1 { | |
1 | |
} else { | |
n * factorial(n - 1) | |
} | |
} | |
#[cfg(test)] | |
mod tests { | |
use crate::factorial; | |
#[test] | |
fn first() { | |
assert_eq!(factorial(0), 1); | |
} | |
#[test] | |
fn fifth() { | |
assert_eq!(factorial(4), 24); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment