More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. import java.util.Scanner;
public class Prime
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter n to compute the nth prime number: ");
int nth = sc.nextInt();
int num, count, i;
num=1;
count=0;
while (count < nth){
num=num 1;
for (i = 2; i <= num; i )
{
if (num % i == 0)
{
break;
}
}
if ( i == num)
{
count = count 1;
}
}
System.out.println("Value of nth prime: " num);
}
}
Help us improve. Please let us know the company, where you were asked this question :