fact n = loop 1 n with loop p n = if n>0 then loop (p*n) (n-1) else p; end;