About 591,000 results
Open links in new tab
  1. Finding prime number in a range in javascript - Stack Overflow

    Jun 30, 2021 · A better approach is to write a function isPrime(number) that returns a boolean and to call it in the loop for each value of i. Split your problems into smaller problems and handle them one at a time.

  2. JavaScript Program to Check Prime Number

    The for loop is used to iterate through the positive numbers to check if the number entered by the user is divisible by positive numbers (2 to user-entered number divided by 2).

  3. Javascript Program for Prime Numbers - GeeksforGeeks

    Aug 28, 2024 · Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + - - - - - - upto n terms. What are prime numbers? A prime number is a natural number greater than 1, which is only divisible by 1 and itself. The first few prime numbers are 2 3 5 7 11 13 17 19 23…

  4. Check Number prime in JavaScript - Stack Overflow

    Instead of return num !== 1 && num !== 0; you can just use condition return num >= 2; since prime numbers must be natural numbers greater than 1.

  5. Check Prime Number in JavaScript (5 Programs) - WsCube Tech …

    Jan 24, 2024 · To check for a prime number in JavaScript using a for loop with user input, we can write a simple function and then call it with a number provided by the user. This is the simplest approach to understanding prime number validation.

  6. JavaScript Program to Print Prime Numbers from 1 to N

    Feb 19, 2024 · printPrimeNumbers (n) function: This function prints all prime numbers up to a given number n. It iterates from 2 to n and uses the isPrime function to check if each number is prime.

  7. 4 ways in JavaScript to find if a number is prime or not

    Jun 8, 2023 · Here, we are calling the isPrime method to check if a number is prime or not. The for loop runs from j = 1 to j = 100 and appends all prime numbers to the array result.

  8. JavaScript Program to Check Prime Number By Creating a Function

    Feb 19, 2024 · In this article, we will explore how to check if a given number is a prime number in JavaScript by creating a function. The basic method to check for a prime number is by using a loop to divide the number by each integer less than its square root. We can also use JavaScript array methods to create a more functional approach.

  9. How can I find the prime factors of an integer in JavaScript?

    JavaScript allows up to 2^53 of integer precision. I tried primeFactors(2**50 - 2), had it run for an hour, and it didn't finish. Here's a working solution: const primeArray = [];

  10. Coding : Identifying Prime Numbers within the given Number in JavaScript

    Jan 22, 2023 · The findPrimes() function starts by declaring an empty array called primes. It then uses a for loop to iterate through all numbers between 2 and the input number.

  11. Some results have been removed
Refresh