DEV Community

Discussion on: Square a number: awful answers only

Collapse
 
_garybell profile image
Gary Bell
function square(int $root): int
{
    $answer = 0;
    for ($i = 1; $i <= $root; $i++) {
        for ($j = 1; $j <= $root; $j++) {
            $answer++;
        }
    }
    return $answer;
}
Enter fullscreen mode Exit fullscreen mode

Just keep adding 1. It will get there