Find a square number

I am trying out kata on codewars and I got a kata that ask for a square, a perfect square which has same item on row and col. I am not a maths person and I had to google to find what is square number, but google says 3*3 = 9 which is a square number but the kata says it is wrong. What am i missing?

How to I break the problem even more. Link to kata

My code so far which is passing 50/50

var isSquare = function(n){
  if(n >=0 && n/2 !== 0){
    return true
      return false;

When we talk about a square number, we are usually talking about a perfect square, a number that can be gotten by multiplying an integer by itself. For example, 4 is square because you can multiply 2 by 2 and get it. So is 9 (3x3) and 25 (5x5). The first 10 positive squares are 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100. They are the squares of 1-10,

We call them squares because they can be formed into a square. 4 can be:

1 2
3 4

or 9:

1 2 3
4 5 6 
7 8 9

The number that we multiply by itself to get the square is called the square root. 9 is 3 squared, or we can say that the square root of 9 is 3. Note that 3 is the number or rows and columns in the square diagram above.

Most numbers are not perfect squares because they cannot be arranged into and equal number of rows and columns. Another way to say that is that there is no number that you can multiply by itself to get the target number. Non square numbers would be: 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, etc. Some of those can form rectangles, but they can’t form squares.

So, for your kata, you have to figure out - can this number be the product of an integer (whole number) multiplied by itself. Another way to say that is: Does this number have and integer square root.

You don’t have to be a math expert to be a computer programmer, but you do need some basic math knowledge. I always say that you need at least the math knowledge that most of us got at around age 10-12. If you are lacking, you may want to do some side study and refresh.

Thank you but much of it has passed over my head, I do need those Maths knowledge, any good starting point? I do not regret starting all over again

I don’t know any offhand. I would just google “learn basic math”. Start there. Skip the parts you know and work your way up. Understanding arithmetic and basic set theory is important. The basics of functions, algebra, and geometry would be good, too.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.