Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查一个数字是否可以被 3、5 或 7 之一整除。
我怎么能写出类似的规则-
isDivide(N) :- N mod 3 =:= 0 OR N mod 5 =:= 0 OR N mod 7 =:= 0.
isDivide(N) :- N mod 3 =:= 0. isDivide(N) :- N mod 5 =:= 0. isDivide(N) :- N mod 7 =:= 0.
或者:
isDivide(N) :- N mod 3 =:= 0 ; N mod 5 =:= 0 ; N mod 7 =:= 0.
请注意,;它不是在行尾,而是在下一行的开头。这纯粹是风格问题,但强烈建议遵循它。
;