Education enthusiast. Ex Groupon Merchant Engineering, Engineering and Growth at Verbling (YC'11) and cram school founder in Taiwan.
Currently building Alchemist Camp.
Just for fun I copied your algorithm into Rust to compare!
fnmain(){letnum=10001;println!("Prime number {} is {}",num,get_prime(num));}fnis_prime(n:u32)->bool{matchn{0...1=>false,_=>!(2..n).any(|d|n%d==0),}}fnget_prime(n:u16)->u32{letmutprimes_found=0;letmuti:u32=2;whilen>primes_found{ifis_prime(i){primes_found+=1;}i+=1;}returni-1;}
Results
Language
Version
Time
JS
10.7.3
1.64s
Python
3.7.1
26.24s
Rust
1.35.0
0.78s
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I also get similar results on my system.
Just for fun I copied your algorithm into Rust to compare!
Results