You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

691 B

nextprime

Instructions

Write a function which returns the first prime number which is equal or superior to the u64 passed as parameter.

The function must be optimized in order to avoid time-outs with the tester.

(We consider that only positive numbers can be prime numbers)

Expected function

pub fn next_prime(nbr: u64) -> u64 {

}

Usage

Here is a possible program to test your function :

fn main() {
    println!("The next prime after 4 is: {}", next_prime(4));
    println!("The next prime after 11 is: {}", next_prime(11));
}

And its output :

$ cargo run
The next prime after 4 is: 5
The next prime after 11 is: 11
$