New paste Repaste Download
import java.util.*;
class check_prime
{
    int i,num,count=0,flag,prime_num;
    int find_prime(int x)
    {
        num=1;
       while (count!=x)
       {
        flag=0;
        for(i=2;i<=num/2;i++)
        {
            if(num%2==0)
            {
                flag++;
                break;
            }
        }
        if(flag!=0)
        {
           num++;
        }
        else
        {
            count++;
            prime_num=num;
            num++;
        }
       }
       return prime_num;
     
    }
}
class nth_prime
{
    static  Scanner sc=new Scanner(System.in);
    public static void main(String ars[])
    {
       int m,n,prime,q;
       
      check_prime ob =new check_prime();
      System.out.println("Enter the nth term");
      n=sc.nextInt();
      prime=ob.find_prime(n);
      System.out.println("Required Prime number is "+prime);
      
    }
}
Filename: None. Size: 964b. View raw, , hex, or download this file.

This paste expires on 2025-08-09 08:33:39.371034. Pasted through web.