programmieren-in-rust/aufgaben/sheet02/task1/prime.rs

37 lines
622 B
Rust
Raw Normal View History

2016-11-02 02:01:05 +01:00
//! Aufgabe 2.1: Primzahltest
fn main() {
}
#[test]
fn small_primes() {
assert!(is_prime(2));
assert!(is_prime(3));
assert!(is_prime(5));
assert!(is_prime(7));
}
#[test]
fn small_composites() {
assert!(!is_prime(1));
assert!(!is_prime(4));
assert!(!is_prime(6));
assert!(!is_prime(8));
assert!(!is_prime(9));
}
#[test]
fn large_primes() {
assert!(is_prime(1_300_769));
assert!(is_prime(1_300_297));
assert!(is_prime(7_367_287));
}
#[test]
fn large_composites() {
assert!(!is_prime(908_209));
assert!(!is_prime(3_073_009));
assert!(!is_prime(4_897_369));
}