is prime
This function determines whether n is a prime number or not.
Controller: ideswa
Contents
Interface
C++
IsPrime
boolisPrime( | int | n | ) |
Example
This example computes the first set of prime numbers:#include <iostream> #include <codecogs/maths/discrete/number_theory/is_prime.h> int main(int argc, char **argv) { for(unsigned int i = 2; i < UINT_MAX; i++) { if(isPrime(i)) std::cout << i << std::endl; } return 0; }Output
2, 3, 5, 7, 11, 13, .......... until UINT_MAX!
Parameters
n Input number
Returns
- True or false
Authors
- Ide Swager
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.