When are they the same? When d = n/d, or d^2 = n (n is a perfect square). Therefore, only perfect squares have an odd number of factors (2 * the number of pairs of factors + 1).
It should be clear here that the number of times the nth door is flipped is the number of unique divisors that n has.
For any non-perfect square n, for any divisor p, n/p = q is another divisor not equal to p. So non-perfect square numbers have an even number of divisors.
Perfect square numbers are the only numbers that have an odd number of divisors, which in this game corresponds to being flipped an odd number of times.
So, for any number of lockers/kids, n, the number of open doors is simply floor(sqrt(n)).
25: 1 5 25 (3)
36: 1 2 3 4 6 9 12 18 36 (9)
lockers = ['Closed'] * 101
for i in range(1, 101):
for locker in range(i, 101, i):
lockers[locker] = 'Open' if lockers[locker] == 'Closed' else 'Closed'
print ([locker for locker, value in enumerate(lockers) if value == 'Open'])
>>> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]