Skip to content

Instantly share code, notes, and snippets.

@munisystem
Created January 1, 2016 01:00
Show Gist options
  • Save munisystem/72d448169736d8e7e396 to your computer and use it in GitHub Desktop.
Save munisystem/72d448169736d8e7e396 to your computer and use it in GitHub Desktop.
N!*(N-1)!*...*2!*1!
fact(N, 1) :- N < 1, !.
fact(N, X) :- N1 is N - 1,
fact(N1, Y),
X is N * Y.
multfact(N, 1) :- N < 1, !.
multfact(N, X) :- N1 is N - 1,
multfact(N1, Y),
fact(N, Z),
X is Z * Y.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment