Radical of an integer

Takes less than one second to run:

with (50) {|n|
    say "Radicals of the first #{n} positive integers:"
    1..n -> map { .rad }.each_slice(10, {|*s|
        say s.map { '%2s' % _ }.join(' ')
    })
}

say ''; [99999, 499999, 999999].map {|n|
    say "rad(#{n}) = #{rad(n)}"
}

for limit in (1e6, 1e7, 1e8, 1e9) {
    say "\nCounting of k-omega primes <= #{limit.commify}:"
    for k in (1..Inf) {
        break if (pn_primorial(k) > limit)
        var c = k.omega_prime_count(limit)
        say "#{k}: #{c}"
        assert_eq(c, limit.prime_power_count) if (k == 1)
    }
}

Output:

Last updated

Was this helpful?