Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Java by s.r ( 14 years ago )
import java.util.Scanner;
public class test {
  public static void main(String args[]) {
    Scanner in = new Scanner(System.in);
    long i,tof;
    int n,j,ii;
    boolean test;
    long a[];
    n = in.nextInt();
    a = new long[n];
    a[0] = 2;
    ii = 1;
    for(i = 3; ii < n; i+=2) {
      tof = Math.round(Math.sqrt(i) - 0.5);
      test = true;
      for(j = 0; a[j] <= tof; j++)
        if (i % a[j] == 0)
          test = false;
      if (test) {
        a[ii] = i;
        ii++;
      }
    }
    System.out.println(a[a.length - 1]);
  }
}

 

Revise this Paste

Parent: 22264
Your Name: Code Language: