This repository has been archived on 2026-03-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
timeshift/src/main.rs

41 lines
650 B
Rust
Raw Normal View History

2026-03-03 08:31:19 -06:00
fn main() {
let src = 12;
let result = is_even(src);
println!("{src} is even? {result}");
}
fn is_even(n: u32) -> bool {
match n {
0 => true,
1 => false,
_ => is_odd(n - 1),
}
}
fn is_odd(n: u32) -> bool {
match n {
0 => false,
1 => true,
_ => is_even(n - 1),
}
}
#[cfg(test)]
mod tests {
use crate::{is_even, is_odd};
#[test]
fn it_works() {
let src = 12;
let result = is_even(src);
assert!(result);
}
#[test]
fn it_works_again() {
let src = 5;
let result = is_odd(src);
assert!(result);
}
2026-03-03 08:31:19 -06:00
}