lgstar(1,0).
lgstar(N,Answer):-
(N = 2**x while x is int ->
N > 1,
N1 is N/2,
logbN(N1,2,A),
Answer is A + 1
).
在上面的程序中,我試圖得到lgstar的答案,當N是一個2的冪數時,即我希望的輸出是lgstar(8, x)是X = 3。SWI Prolog程序找到對數
但是,在while x is int
,我收到錯誤
運營商預計
我能給的條件x is int
以這樣的方式?
這個'while'是什麼意思? – false
請不要多次提問。 – false
請通過閱讀[旅遊](http://stackoverflow.com/tour)瞭解本網站的工作原理。 – false