Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
:- module factorial.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- func fact(int) = int.
fact(0) = 1.
fact(N) = N * fact(N-1).
main(!IO) :- io.write_int(fact(5), !IO), io.write_string("\n", !IO).Coding works best on desktop or with an external keyboard.