因子中的 SWISH Prolog 错误

问题描述

fact(0,1).
fact(N,F):-
    (   
        N>0:-
        (   N1 is N-1,fact(N1,f1),F is N*F1
        )
    ;   
    write("N less than 0 nor allowed")
    ).

在教程中,作者的代码是有效的。我写了相同的代码,但我的不起作用。他用 cgwin(即离线)写作,我用 SWISH(即在线)写作。

查询通过:fact(3,R).
错误信息:

Singleton variables: [R]
Singleton variables: [F1]
procedure `(A:-B)' does not exist
Reachable from:
      fact(A,B)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)