Factors of an integer: Difference between revisions

Content added Content deleted
(→‎{{header|MUMPS}}: Added a Mercury implementation.)
Line 1,326: Line 1,326:


This implementation of factoring works as follows:
This implementation of factoring works as follows:
1. The input number itself and 1 are both considered factors.
# The input number itself and 1 are both considered factors.
2. The numbers between 2 and the square root of the input number are checked for even division.
# The numbers between 2 and the square root of the input number are checked for even division.
3. If the incremental number divides evenly into the input number, both the incremental number and the quotient are added to the list of factors.
# If the incremental number divides evenly into the input number, both the incremental number and the quotient are added to the list of factors.


===fac.m===
===fac.m===