0 points

Perfect Square


dashboard

Tue Nov 24 2020 16:21:44 GMT+0000 (UTC)

Posted by @snigdhakhurana10

//Perfect Square without finding square root

function perfectSquare(number) {
  for (let i = 0; i * i <= number; i++) {
    if (number % i === 0 && number / i === i) return true;
  }
  return false;
}

let num = 12;
console.log(perfectSquare(num));
content_copy Copy