Parsing how to judge a number as prime _javascript skill by using JavaScript

Source: Internet
Author: User
Tags numeric value

Is the prime number judged?

Prime numbers (prime number) are also called prime numbers, with an infinite number. A prime number is defined as a number of natural numbers greater than 1, except for 1 and its own no longer have other factors than the numbers called prime numbers.

composite numbers, mathematical expressions, English name composite number, in addition to the natural number can be 1 and its own integer, but also by the number of other (except 0) is divisible. Relative to the prime number (factor only 1 and itself, such as 2,3,5,7,11,13, etc., also known as Prime), and 1 is neither prime nor composite. The smallest composite is 4.

<! DOCTYPE html>  

It is worth noting that here we can use the isNaN () method to determine whether user input is legitimate:

Alert (isNaN (NaN)); True
alert (isNaN);  False (10 is a numeric value)
alert (isNaN ("ten")),//false (can be converted to numeric)
alert (isNaN ("Blue"));//true (cannot be converted to numeric values)
Alert (isNaN (true));//false (can be converted to a value of 1)

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, if there are questions you can message exchange, but also hope that a lot of support cloud Habitat community!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.