Course Computational Mathematics
Primality Test
In this lesson, we'll learn how to check whether a number is prime or not.
First, let's recall what a prime number is. A number
Given this definition of prime numbers, there is a simple question we can ask ourselves: how to check if a number is prime?
The naive idea is to iterate over all numbers
The complexity of this algorithm is
#include <iostream>
using namespace std;
int main()
{
int p;
cin >> p;
bool isPrime = true;