Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Reduced all possibilities of a number which cannot be prime. Eg: No even number, except 2 can be a prime number, hence we will increment our loop with i+6 jumping and check for i or i+2 to be a factor of the number; if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num) More...
#include <cassert>
#include <iostream>
Functions | |
template<typename T > | |
bool | is_prime (T num) |
for IO operations More... | |
int | main () |
Reduced all possibilities of a number which cannot be prime. Eg: No even number, except 2 can be a prime number, hence we will increment our loop with i+6 jumping and check for i or i+2 to be a factor of the number; if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num)
Copyright 2020
A simple program to check if the given number if prime or not.
bool is_prime | ( | T | num | ) |
for IO operations
for assert Function to check if the given number is prime or not.
num | number to be checked. |
int main | ( | void | ) |
Main function