I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.10
sub units 0.00
+
0

Primes

viewed 2618 times and licensed 43 times
Returns the prime number of order \e n.
Controller: CodeCogs

Interface

C++

Primes

 
intprimesintn )
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  23

References

SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cppsrc/subset/subset.html

Parameters

nthe desired order (between 0 and 1600)

Returns

the prime number of order n

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.