Factors of an integer: Difference between revisions

Content added Content deleted
Line 1,329: Line 1,329:
list.sort_and_remove_dups([1, N | Unsorted], Factors).
list.sort_and_remove_dups([1, N | Unsorted], Factors).
:- pred factor(int::in, int::in, int::in, list(int)::in, list(int)::out) is det.
:- pred factor(int, int, int, list(int), list(int)).
:- mode factor(in, in, in, in, out) is det.
factor(N, X, Limit, !Accumulator) :-
factor(N, X, Limit, !Accumulator) :-
( if X > Limit
( if X > Limit
Line 1,342: Line 1,343:
factor(N) = Factors :- factor(N, Factors).
factor(N) = Factors :- factor(N, Factors).


:- end_module fac.
:- end_module fac.</lang>
</lang>


===Use and output===
===Use and output===