Jump to content

Factors of an integer: Difference between revisions

→‎{{header|Mercury}}: Updated the explanation to match new code.
(→‎fac.m: Replaced implementation with a tail-recursive implementation that does magic.)
(→‎{{header|Mercury}}: Updated the explanation to match new code.)
Line 1,278:
# The numbers between 2 and the square root of the input number are checked for even division.
# If the incremental number divides evenly into the input number, both the incremental number and the quotient are added to the list of factors.
 
Note that this implementation is tail-recursive and uses tricks of unification to "magically" pull the "L" variable seemingly out of thin air.
 
===fac.m===
Cookies help us deliver our services. By using our services, you agree to our use of cookies.