FUNCTION
Primes
Returns the prime number of order \e n.
Interface
#include <codecogs/maths/discrete/number_theory/primes.h>
using namespace Maths::Discrete::Number_Theory;
This function returns one of the first <em> 1600 </em> prime numbers directly, starting with 2, 3, and ending with 13499. A null value of the order is also valid, generating the result 1.
Example 1
#include <codecogs/maths/discrete/number_theory/primes.h>
#include <iostream>
int main()
{
std::cout << "The first 10 prime numbers" << std::endl;
for (int i = 1; i < 10; i++)
std::cout << Maths::Discrete::NumberTheory::primes(i) << " ";
std::cout << std::endl;
return 0;
}Output:
The first 10 prime numbers
2 3 5 7 11 13 17 19 23Parameters
n
the desired order (between 0 and 1600)
Returns
the prime number of order n
References
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp\_src/subset/subset.html
Interactive Calculator
n
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.