#K65222. Find the nth Prime Number
Find the nth Prime Number
Find the nth Prime Number
Given a positive integer n, your task is to compute the nth prime number. A prime number is a number greater than 1 that has no divisors other than 1 and itself. Formally, a number p is prime if:
\(p > 1\) and for every integer \(d\) such that \(2 \le d \le \sqrt{p}\), \(d\) does not divide \(p\).
If the input n is less than 1, then you must output the error message: n must be a positive integer greater than 0
.
For example:
- When n = 1, the output should be 2 (since 2 is the first prime).
- When n = 5, the output should be 11.
inputFormat
The input consists of a single line containing a positive integer n (\(n \ge 1\)).
outputFormat
If n is a valid positive integer, output the nth prime number on a single line. Otherwise, output the error message: n must be a positive integer greater than 0
.
1
2