We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Explanation of what the algorithm is actually doing.
For any number there will always be a pair of factors, a and b, for that number. Example for 24: 1&24, 2&12, 3&8, 4&6.
Due to this, the result will by default be an even number. However the only exception is when a number has an integer square root, as the root is only counted once towards the factors.
So the problem finds the integer root and checks if that root squared is equal to the original number. If so, then the answer is YES.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Smart Number
You are viewing a single comment's thread. Return to all comments →
Explanation of what the algorithm is actually doing.
For any number there will always be a pair of factors, a and b, for that number. Example for 24: 1&24, 2&12, 3&8, 4&6.
Due to this, the result will by default be an even number. However the only exception is when a number has an integer square root, as the root is only counted once towards the factors.
So the problem finds the integer root and checks if that root squared is equal to the original number. If so, then the answer is YES.