#!/usr/bin/ruby

for n in (1..100) {
    var k = irand(1e7)

    say "Testing k=#{k}"

    var p = k.nth_prime

    assert(p.is_prime)

    if (p.prime_count != k) {
        die "Error for k=#{k}"
    }
}

for n in (1..10) {
    var k = 10**n

    say "Testing k=#{k}"

    var p = k.nth_prime

    assert(p.is_prime)

    if (p.prime_count != k) {
        die "Error for k=#{k}"
    }
}

for n in (1..10) {
    var k = (10**n + irand(1e5))

    say "Testing k=#{k}"

    var p = k.nth_prime

    assert(p.is_prime)

    if (p.prime_count != k) {
        die "Error for k=#{k}"
    }
}

for n in (1..8) {
    var k = abs(10**n - irand(1e3))

    say "Testing k=#{k}"

    var p = k.nth_prime

    assert(p.is_prime)

    if (p.prime_count != k) {
        die "Error for k=#{k}"
    }
}
