mirror of
https://github.com/TheAlgorithms/PHP.git
synced 2025-07-10 03:26:19 +02:00
16 lines
398 B
PHP
16 lines
398 B
PHP
<?php
|
|
|
|
/**
|
|
* This function check whether
|
|
* the provided number is a
|
|
* perfect square or not.
|
|
*
|
|
* @param Decimal $number A decimal input
|
|
* @return boolean whether the number is perfect square or not
|
|
*/
|
|
function isPerfectSquare($number)
|
|
{
|
|
$root = (int) sqrt($number);
|
|
return (($root * $root) === $number); // If number's square root is an integer then it's a perfect square else not
|
|
}
|