RosettaCodeData/Task/Factorial/Maude/factorial.maude
2016-12-05 23:44:36 +01:00

15 lines
200 B
Text

fmod FACTORIAL is
protecting INT .
op undefined : -> Int .
op _! : Int -> Int .
var n : Int .
eq 0 ! = 1 .
eq n ! = if n < 0 then undefined else n * (sd(n, 1) !) fi .
endfm
red 11 ! .