Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #361 Test for perfect squarity

Set the boolean b to true if the integer n is a square number, false otherwise

E.g. 2025true

import static java.lang.Math.sqrt;
boolean b = sqrt(n) % 1 == 0;

New implementation...
< >
steenslag