Input: 13195 Expected Result: 29 (largest prime factor of input) Actual Result: 2639 (largest factor of input, but not a prime number) I didn't bother with even numbers because the largest prime will either be 2 or some odd prime multiplied by 2...

I am trying to determine whether the value in a text box is prime or not using jQuery. Here is what I've tried so far, but it's not working: $("#textbx").keyup(function(){ if ($("#textbx").val().length > 0) { $("...

And how can I correct them to work? I am trying to optimize my sieve per previous suggestions, but in both instances the code breaks: Incrementing j = j + ( i * 2) will break the code. Obviously I'm missing some concept on optimizations as well...

I have an input field to take a maximum number and find all smaller prime numbers. It should return to an array and display the array with an alert. Except I'm getting blank every time. HTML: <p>Please enter the maximum number you'd...

So I wanted to write a function that returns the sum of all prime numbers up to and including a provided number. I have written this, which works: function sumPrimes(num) { const arr = Array.from({length: num+1}, (v, k) => k).slice(2); re...

I'm trying to sum all primes up to a number. First I removed all evens and pushed the rest to an odd-only array. Then i'm going over the array and splicing all the numbers that divide by other numbers but 1 and themselves, and replacing the...

My task is to produce an array containing all the prime numbers up to a 12-digit number. I tried to emulate the Sieve of Eratosthenes by first making a function enumerate that produces an array containing every integer from 2 to num: var enumerate...

I've got an assignment to write a js code using only loops that recieves a number from a user and prints out all the prime numbers between 1 and that number. Thats what I've done, but its not working as I expect it to, cant find what Im miss...

I made this prime factorization program that works really well.The only problem is that, when the input is a large number it freezes the browser. My goal is to make the whole calculation last longer, and not freeze the browser. I have tried several m...

©2020 All rights reserved.