Want to improve this post? Provide detailed answers to...
I recently read about a faster implementation of Segmented Sieve of Eratosthenes for really big numbers.  Following is an implementation of the same:  function sieve(low, high) {      var primeArray = [], ll = Math.sqrt(low), output = [];      for (v...
My problem is to compute (g^x) mod p quickly in JavaScript, where ^ is exponentiation, mod is the modulo operation. All inputs are nonnegative integers, x has about 256 bits, and p is a prime number of 2048 bits, and g may have up to 2048 bits.  Most...
I wrote two prime finder functions and the sieve only performs about 10% better.  I'm using two optimizations for the simple version.   Don't check even numbers  Only check up to the square root or j * j <= i. ( equivalent )   and one opti...
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 have been trying to write Sieve of Eratosthenes algorithm in JavaScript. Basically I just literally followed the steps below:   Create a list of consecutive integers from 2 to (n-1) Let first prime number p equal 2 Starting from p, count up in incr...
I try to implement the Lucas–Lehmer test (LLT) primality test for Mersenne numbers (https://en.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test). It should be polynomial and hence fast. Here is my code:  function countPrimeNumberWithDigits(nu...
I'm new to javascript and was trying to find the prime factors of a number, recorded below as 'integer' using a for loop in javascript. I can't seem to get it working and I'm not sure whether it's my javascript or my calculati...
I need to generate a random big (around 4096 bit) prime number in JavaScript and I'm already using forge. Forge has to have some kind of generator for such tasks as it implements RSA which also relies on random prime numbers. However I haven'...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.