The answer is 31.

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

A cell will remain open if it has been switched odd number of times.

Any number (prime or not) can be written as product of 2 different numbers.

Let's take example of 12: 12=1x12 =2x6 =3x4

So 12 will switch 6 times on: 1, 2, 3, 4, 6, 12

But we can notice that square numbers will switch odd times. Say

36=1x36 =2x18 =3x12 =4x9 =6x6

So 36 will switch 9 times on: 1, 2, 3, 4, 6, 9, 12, 18, 36

Between 1&1000, 31 squares are there (31²=961)

So answer=31