
write a program to find the 100th or nth primary number?

import java.util.*;
class PrimeNumber{
public static void main(String a[]) {
Scanner input=new Scanner(System.in);
System.out.print("Enter N:");
int n=input.nextInt();
find(n);
}
static void find(int n){
int i=0,count=2;
if(n==1)
{
return;
}
if(n==2)
{
return;
}
while(true)
{
for(int j=2;j<=i/2;j++){
if(i%j==0)
break;
else if(j==i/2)
{
count++;
}
}
if(count==n)
{
System.out.println(n+"th prime = "+i);
break;
}
i++;
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.