0

A semiprime number is defined as a natural number that is the product of two prime numbers. For example, 21 is a semiprime (3 * 7) or 25 (5 * 5).

I've been looking to try and create a function that could take a semiprime number as it's input and return the two prime numbers which are the prime factors of that input. I've been struggling to come up with ideas. Could anyone help to think of a method of approaching this?

DPJDPJ
  • 147
  • 2
  • 9
  • There are various integer factoring algorithms, if you specify the approximate size of number that you're interested in (or any particular properties that might help) then a specific one could be recommended. – harold Nov 12 '20 at 15:19
  • The best place to start looking for answers to wide open questions like these is usually wikipedia. Please read [this entry](https://en.wikipedia.org/wiki/Integer_factorization). Note that the size of the number (in digits) that is being factored is a very important input in determining the most appropriate algorithm. Smaller numbers can be efficiently factored with reasonably simple algorithms, but larger ones require more advanced and complicated techniques that require a lot of code. – President James K. Polk Nov 12 '20 at 17:35

0 Answers0