Skip to main content
Code Review

Return to Answer

Spelling fixes
Source Link
Toby Speight
  • 87k
  • 14
  • 104
  • 322

N >= 6 would have to be the sum of two odd primes. An odd number xx is prime with probability about 2/ln xx. XX and nn - xx are two primes with probability about 1 / ln^2 nln2 n, so you need to examine about ln^2 nln2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size nn is very inefficient. It takes nn steps when you usually need just ln^2 nln2 n. So create one sieve for the numbers c x ln^2 ncxln2 n and one for the numbers nn - c x ln^2 ncx ln2 n to nn. Experiment to find a "c""c" that usually finds a solution, and if it doesn’t work then repeat with 2c2c instead of cc.

Now if you wanted to check all even 6 <= N <= 10^9N ≤ 109 then you would create one large sieve.

N >= 6 would have to be the sum of two odd primes. An odd number x is prime with probability about 2/ln x. X and n - x are two primes with probability about 1 / ln^2 n, so you need to examine about ln^2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size n is very inefficient. It takes n steps when you usually need just ln^2 n. So create one sieve for the numbers c x ln^2 n and one for the numbers n - c x ln^2 n to n. Experiment to find a "c" that usually finds a solution, and if it doesn’t work then repeat with 2c instead of c.

Now if you wanted to check all even 6 <= N <= 10^9 then you would create one large sieve.

N 6 would have to be the sum of two odd primes. An odd number x is prime with probability about 2/ln x. X and n - x are two primes with probability about 1 / ln2 n, so you need to examine about ln2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size n is very inefficient. It takes n steps when you usually need just ln2 n. So create one sieve for the numbers cxln2 n and one for the numbers n - cx ln2 n to n. Experiment to find a "c" that usually finds a solution, and if it doesn’t work then repeat with 2c instead of c.

Now if you wanted to check all even 6 N ≤ 109 then you would create one large sieve.

added 98 characters in body
Source Link
gnasher729
  • 2.9k
  • 14
  • 13

N >= 6 would have to be the sum of two odd primes. An odd number x is prime with probability about 2/ln x. X and n - x are two primes with probability about 1 / ln^2 n, so you need to examine about ln^2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size n is very inefficient. It takes n steps when you usually need just ln^2 n. So create one sieve for the numbers c x ln^2 n and one for the numbers n - c x ln^2 n to n. Experiment to find a "c" that usually finds a solution, and if it doesn’t work then repeat with 2c instead of c.

Now if you wanted to check all even 6 <= N <= 10^9 then you would create one large sieve.

N >= 6 would have to be the sum of two odd primes. An odd number x is prime with probability about 2/ln x. X and n - x are two primes with probability about 1 / ln^2 n, so you need to examine about ln^2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size n is very inefficient. It takes n steps when you usually need just ln^2 n. So create one sieve for the numbers c x ln^2 n and one for the numbers n - c x ln^2 n to n. Experiment to find a "c" that usually finds a solution, and if it doesn’t work then repeat with 2c instead of c.

N >= 6 would have to be the sum of two odd primes. An odd number x is prime with probability about 2/ln x. X and n - x are two primes with probability about 1 / ln^2 n, so you need to examine about ln^2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size n is very inefficient. It takes n steps when you usually need just ln^2 n. So create one sieve for the numbers c x ln^2 n and one for the numbers n - c x ln^2 n to n. Experiment to find a "c" that usually finds a solution, and if it doesn’t work then repeat with 2c instead of c.

Now if you wanted to check all even 6 <= N <= 10^9 then you would create one large sieve.

Source Link
gnasher729
  • 2.9k
  • 14
  • 13

N >= 6 would have to be the sum of two odd primes. An odd number x is prime with probability about 2/ln x. X and n - x are two primes with probability about 1 / ln^2 n, so you need to examine about ln^2 n pairs of numbers to find a pair of primes.

So that shows that creating a sieve of size n is very inefficient. It takes n steps when you usually need just ln^2 n. So create one sieve for the numbers c x ln^2 n and one for the numbers n - c x ln^2 n to n. Experiment to find a "c" that usually finds a solution, and if it doesn’t work then repeat with 2c instead of c.

lang-rb

AltStyle によって変換されたページ (->オリジナル) /