bishwobista / crack-code

Crack all the coding questions.
6 stars 42 forks source link

Create a simple JavaScript program that checks whether a given number is prime or not. #115 #116

Closed P0Saurabh closed 1 year ago

P0Saurabh commented 1 year ago

Add #115 This JavaScript program defines a function isPrime that checks whether a given number is prime or not. It first handles some special cases and then uses a primality test based on the fact that all prime numbers (except 2 and 3) can be expressed in the form 6k ± 1.

You can change the value of the num variable to any number you want to check for primality. The program will then output whether the number is prime or not.