Legendre prime counting function: Difference between revisions

Content added Content deleted
m (add some compiler optimizations)
m (→‎{{header|Vlang}}: Fixed trivial cases n = 3 to 8 (see talk page).)
Line 3,363: Line 3,363:
[direct_array_access]
[direct_array_access]
fn count_primes_to(n u64) i64 {
fn count_primes_to(n u64) i64 {
if n < u64(3) { return if n < i64(2) { i64(0) } else { i64(1) } }
if n < u64(9) { return if n < i64(2) { i64(0) } else { i64((n + 1) / 2) } }
rtlmt := u64(sqrt(f64(n)))
rtlmt := u64(sqrt(f64(n)))
mxndx := i64((rtlmt - 1) / 2)
mxndx := i64((rtlmt - 1) / 2)