He's checking to see if the sqrt() function has decimals by comparing the base sqrt(n) to the rounded down version (floor()) of sqrt(n). If they are equal and the function returns true, then sqrt(n) must have no decimals. Thus, n is a perfect square.
sqrt is calculated 2 times :(
Nice, it takes off the decimal and checks it aginst the actual case. Cool solution!
He's checking to see if the sqrt() function has decimals by comparing the base sqrt(n) to the rounded down version (floor()) of sqrt(n). If they are equal and the function returns true, then sqrt(n) must have no decimals. Thus, n is a perfect square.
why are you using floor specifically?
floor in C++
What does the function floor do?