Please read the new rule regarding the restriction on the use of AI tools. ×

Moody_Nabil's blog

By Moody_Nabil, history, 2 years ago, In English

Is there any way to get all prime numbers tell 1e8??

I am stuck in this problem Printing some primes

  • Vote: I like it
  • -10
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

One of the ways I can think is by using a Segmented Sieve which is an extension of the Sieve of Eratosthenes. A segmented sieve works well for large ranges, unlike the Sieve of Eratosthenes. You can check the algorithm on this site: https://www.geeksforgeeks.org/segmented-sieve-print-primes-in-a-range/?ref=lbp

»
2 years ago, # |
  Vote: I like it +8 Vote: I do not like it

возможно тест Миллера-рабина O(log n)