Finding all cube roots with a number as a limit
问题 I want to find all of the cube roots that their cubes + their remainder add up to a number to user inputs. So for example, the query: ?- smallerCube(X,20). Would give the result: 1 remainder 19 2 remainder 12 Since 1^3 = 1 (remainder 19), 2^3 = 8(remainder 12) and 3^3 = 27 which is bigger than the initial input of 20, and hence it's not being calculated here. So far this is my code: cubeLess(X,B,R) :- X =< B, X1 is X*X*X, R is B-X1. smallerCube(X,B) :- int(X), X2 is X*X*X, X2 =< B, cubeLess