Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email 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 C++ by s.r ( 14 years ago )
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
  unsigned long n,i,j,tof,ii;
  bool test;
  vector<unsigned long> a;
  cin >> n;
  a.resize(n);
  a[0] = 2;
  ii = 1;
  for(i = 3; ii < n; i+=2) {
    tof = sqrt(i);
    test = true;
    for(j = 0; a[j] <= tof; j++)
      if (i % a[j] == 0)
        test = false;
    if (test) {
      a[ii] = i;
      ii++;
    }
  }
  cout << a[a.size() - 1] << endl;
}

 

Revise this Paste

Parent: 22263
Children: 22265
Your Name: Code Language: