All of sudden, I have to factorize some integers. Since I did not suppose my integers to be very big numbers, I've implemented trial division method. Method description is below the calculator.
In number theory, integer factorization or prime factorization is the decomposition of a composite number into smaller non-trivial divisors, which when multiplied together equal the original integer.
And, since trial division is the easiest to understand of the integer factorization algorithms, here are couple of sentences from wikipedia:
Given an integer n (the integer to be factored), trial division consists of systematically testing whether n is divisible by any smaller number. Clearly, it is only worthwhile to test candidate factors less than n, and in order from two upwards because an arbitrary n is more likely to be divisible by two than by three, and so on.
With this ordering, there is no point in testing for divisibility by four if the number has already been determined not divisible by two, and so on for three and any multiple of three, etc.
Therefore, effort can be reduced by selecting only prime numbers as candidate factors. Furthermore, the trial factors need go no further than because, if n is divisible by some number p, then n = p × q and if q were smaller than p, n would have earlier been detected as being divisible by q or a prime factor of q.
Trial division is a laborious algorithm, yet it is good for small numbers. More can be found at wiki link above.