Блог пользователя Lord_David

Автор Lord_David, история, 3 года назад, По-английски

So I've got a question about problems that need prime numbers. How are you meant to approach them? More specifically, how do you approach problems that require you to calculate prime numbers and do something with them? Do you implement/copy paste something like the sieve of Eratosthenes every time or is there a better method? Thanks in advance.

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Your question sounds ambiguous to me so I cannot really fully answer it. The most important thing is, there is no rule to solve all problems. Prime numbers might occur in different ways and each problem will be different from other. That's why you should solve more problems to understand how primes might come in handy.

While solving problems, you will learn how to solve specific problems e.g. prime factorization in $$$O(logn)$$$ or check primality in more efficient way. If you want to learn more about primes (or number theory as a whole) then I suggest you to read this.