// Prime counting benchmark
const std = @import("std");

fn isPrime(n: i64) bool {
    if (n < 2) return false;
    if (n == 2) return true;
    if (@mod(n, 2) == 0) return false;
    var i: i64 = 3;
    while (i * i <= n) : (i += 2) {
        if (@mod(n, i) == 0) return false;
    }
    return true;
}

fn countPrimes(max: i64) i64 {
    var count: i64 = 0;
    var i: i64 = 2;
    while (i <= max) : (i += 1) {
        if (isPrime(i)) count += 1;
    }
    return count;
}

pub fn main() void {
    const count = countPrimes(10000);
    std.debug.print("Primes up to 10000: {d}\n", .{count});
}
