Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ primality test

#include <iostream>
using namespace std;
bool isPrimeNumber(int n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
  
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
  
    return true;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: flutter margins 
Cpp :: std logic vhdl 
Cpp :: suppress individual warnings in visual c++ 
Cpp :: how to print list in c++ 
Cpp :: arduino for command 
Cpp :: remove or erase first and last character of string c++ 
Cpp :: qt change window title 
Cpp :: c++ int to qstring 
Cpp :: how to use winmain function 
Cpp :: c++ read console input 
Cpp :: como medir tiempo de ejecucion cpp 
Cpp :: c++ custom compare in set 
Cpp :: how to shut down windows in c++ 
Cpp :: eosio multi index clear 
Cpp :: arduino get size of array 
Cpp :: is there an algorithm to create a truly random password 
Cpp :: set platformio to C++14 
Cpp :: how to interface c++ in haxe 
Cpp :: integer to string c++ 
Cpp :: initialzing a 2d vector in cpp 
Cpp :: read variable to file cpp 
Cpp :: ifstream relative file path 
Cpp :: recursive power in c++ 
Cpp :: input a string in c++ 
Cpp :: how to open and print in a file in c++ 
Cpp :: convert decimal to binary c++ 
Cpp :: loop through char in string c++ 
Cpp :: c++ kruskal algorithm 
Cpp :: c++ array loop 
Cpp :: c++ measure time in microseconds 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =