File: nth_prime.cpp

package info (click to toggle)
primesieve 12.11%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,952 kB
  • sloc: cpp: 16,515; ansic: 723; sh: 536; makefile: 91
file content (20 lines) | stat: -rw-r--r-- 358 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// @example nth_prime.cpp
/// Find the nth prime.

#include <primesieve.hpp>
#include <stdint.h>
#include <iostream>
#include <cstdlib>

int main(int, char** argv)
{
  uint64_t n = 1000;

  if (argv[1])
    n = std::atol(argv[1]);

  uint64_t nth_prime = primesieve::nth_prime(n);
  std::cout << n << "th prime = " << nth_prime << std::endl;

  return 0;
}