fork download
  1. ; your code goes here
  2.  
  3. (defrule factorial
  4. (fact_run ?x)
  5. =>
  6. (assert (fact ?x 1)))
  7.  
  8. (defrule fact_helper
  9. (fact ?x ?y)
  10. (test (> ?x 0))
  11. =>
  12. (assert (fact (- ?x 1) (* ?x ?y))))
  13.  
  14. (assert (fact_run 5))
  15.  
  16. (assert (fact_run 5))
  17. (run)
  18. (facts)
  19.  
  20. (exit)
  21. ; empty line at the end
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
f-0     (initial-fact)
f-1     (fact_run 5)
f-2     (fact 5 1)
f-3     (fact 4 5)
f-4     (fact 3 20)
f-5     (fact 2 60)
f-6     (fact 1 120)
f-7     (fact 0 120)
For a total of 8 facts.