This program starts operation by showing output "Input a number to see if it's a prime number"
When user inputs a number, it calls function isPrimeNumber to check if it's a prime number.
After the operation, the program shows if it's a prime number or not
The isPrimeNumber() function determines if a number is prime by following an efficient approach.
First, it checks if the number is less than or equal to 1, returning false since numbers less than or equal to 1 are not prime. If the number is 2 or 3, it returns true because both are prime numbers.
Next, the function checks if the number is divisible by 2 or 3—if so, it returns false, as any number divisible by these is not prime (except 2 and 3 themselves).
For larger numbers, the function uses a loop starting from 5 and increments by 6. This optimization checks divisibility only by numbers of the form 6k ± 1 skipping multiples of 2 and 3 to reduce unnecessary checks. If the number is divisible by any of these, the function returns false; otherwise, it returns true, indicating the number is prime.
The loop runs up to the square root of the number to further optimize performance.