![]() ![]() Numbers greater than 1 are tested using a for loop.All negative numbers are excluded because prime numbers are positive.1 is considered neither prime nor composite.The number entered by the user is checked if it is greater than 1 using if.else if. W3Schools is getting more than 35 million visits per month and it is the most popular web development. ![]() ![]() It covers topics like HTML, CSS, JavaScript, PHP, ASP.Net, SQL, and many more. W3Schools is an educational website that provides web development tutorials. W3Schools maintains a complete JavaScript reference, including all HTML and browser objects. W3Schools is a web developer information website, with tutorials and references relating to web development topics such as HTML, CSS, JavaScript, PHP, SQL. ES13 or ES2022 or EcmaScript2022 features. Here you get the link for w3schools offline version download (latest full website). In the above program, the user is prompted to enter a number. This tutorial covers latest new JavaScript features will release in 2022. Example: Check Prime Number // program to check if a number is prime or notĬonst number = parseInt(prompt("Enter a positive number: ")) Ĭonsole.log("1 is neither prime nor composite number.") Ĭonsole.log(`$ is a not prime number`) Ĭonsole.log("The number is not a prime number.") For example, 2, 3, 5, 7, 11 are the first few prime numbers. A prime number is a positive integer that is only divisible by 1 and itself.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |