可能重複:
Fastest way to determine if an integer's square root is an integer任何人都知道邏輯找出一個數字是完美的正方形?
有誰知道邏輯要找出一個數是完全平方與否? (Other than Newtons Method or Synthetic Division Method
)
For Eg:- 4, 16, 36, 64 are Perfect Squares.
我將會給輸入爲441
,邏輯應該說無論是其完美的正方形或沒有。
這是亞馬遜採訪中提出的一個問題。
我想與做出來的任何內置函數
[?什麼是好的算法,以確定是否輸入是一個完美的正方形(http://stackoverflow.com/questions/343852/whats-a-good-algorithm-to-determine-if-an-input-is-a-perfect-square) –
如果技巧是在輸入本身,那麼,因爲441有一個在右邊,那麼沒辦法可能是一個完美的廣場。 –
@Jalal:像81一樣不是什麼? :-) – regularfry