Loop_Practise_Que_04

Home / Java Practice Question / Loop_Practise_Que_04

Loop_Practise_Que_04


WAP to print the Nth Prime Number 

Program : - 


public class Loop{
   public static int NthPrime(int num)
{
int i=2;
int count=0;
int ans=0;
while(true)
{
if(num==count)
{
break;
}
if(isprime(i))
{
count++;
ans=i;
}
i++;
}
return ans;
}
}