Check whether given number is prime or not – JavaScript

preview_player
Показать описание
Today we are going to attend a question.

Write a JavaScript program to check whether number given is a prime number or not. If the number is prime then print number to the document along with the text “it is a prime number”.

First of all, what is a prime number?

A natural number greater than one has not any other divisors except 1 and itself. In other word we can say which has only two divisors, 1 and the number itself. For example, 5 is a prime number and cannot be divided by 1 or itself.

Рекомендации по теме