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

Автор PBBx0, 4 месяца назад, По-английски

Few people know, but UNIX-like operating systems have a built-in ‘factor’ function that is used to... factorize numbers (surprise surprise). And it does it extremely fast. I mean incredibly fast. Just try it.

And it gives us a silly but charming way to find prime numbers: to check if a number is prime, just call ‘factor’ and make sure the result contains a single number.

With a little familiarity with bash you can write scripts for something like finding next prime or anything

Github

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

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

Just fyi, almost every factoring algorithm has a computational complexity proportional to the biggest or second biggest factor. Ironically it’s kind of hard to design an algorithm worse than that.