def newman_prime(n):
    if n <= 0:
        raise ValueError("n must be a positive integer")

    def is_prime(x):
        if x < 2:
            return False
        if x % 2 == 0:
            return x == 2
        if x % 3 == 0:
            return x == 3
        i = 5
        w = 2
        while i * i <= x:
            if x % i == 0:
                return False
            i += w
            w = 6 - w
        return True

    count = 0
    a, b = 1, 1  # S0, S1
    while True:
        if is_prime(a):
            count += 1
            if count == n:
                return a
        a, b = b, 6 * b - a