有没有可能限制一个整数,说它不能是(完美的)平方数?
我有:
square(Square):- N#>0, Square #= N*N.如何定义notsquare(Notsquare):- ...
我的第一个想法是让P*P =Q*Q*Notsquare和Remainder #>0, Remainder #= P rem Q.
但是P和Q需要能够是非整数,所以这不起作用。
发布于 2016-08-18 21:08:56
关于
notSquare(S):- N #> 0, R #>0, R #< 2*N+1, S #= N*N+R.如果为S > 0,应该可以工作;如果您还需要处理负数,我想您可以将其修改为
notSquare(S):- S #> 0, N #> 0, R #>0, R #< 2*N+1, S #= N*N+R.
notSquare(S):- S #< 0, SM #= -S, notSquare(SM).https://stackoverflow.com/questions/39015669
复制相似问题