Advertisement
taweesoft

nPrime1

Aug 7th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Input {
  3.     public static void main(String[] args){
  4.     Scanner sc = new Scanner(System.in);
  5.         int ref=0;
  6.         int a = sc.nextInt();
  7.         int i =0;
  8.         int state=0;
  9.         String prime="";
  10.         if(a==1){
  11.             System.out.println(2);
  12.         }else if(a>1){
  13.             ref=1;
  14.         for(i =2;i<300000;i++){
  15.             for(int j =2;j<i;j++){
  16.                 state = j;
  17.                 if(i%j==0){
  18.                     break;
  19.                 }
  20.             }
  21.             if(state==i-1){
  22.                 ref+=1;
  23.             }
  24.             if(ref==a){
  25.                 System.out.println(i);
  26.                 break;
  27.             }
  28.         }
  29.         }
  30.         }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement