Check whether the number input is a prime number. // Time complexity - O(n) func isPrimeNumber(n int) bool {
if n == 2 {
return true
}
for i := 2; i < n; i++ {
if n%i == 0 {
return false
}
}
return true
} // Time complexity - O(log(n)) func isPrimeNumber(n int) bool {
for i := 2; i < int(math.Sqrt(float64(n))); i++ {
if n%i == 0 {
return false;
}
}
return true;
}