Generation

generate functionSun, 13 Nov 2022

Compute the nth prime number

fn nth(n: u32) -> u32 { let mut primes = Vec::new(); let mut i = 2; while primes.len() < n as usize { if is_prime(i) { primes.push(i); } i += 1; } *primes.last().unwrap() }

Want to kickstart your project?Use the new AI Studio to create your code