A king decides to release all his prisoners on Christmas eve. He has 1000 jail cells of them. He has his jailer unlock all the cell doors. He thinks this is too many to release at once, so he has the jailer go back and starting with door #2 he tells him to turn the key in lock and do this every second door. He then tells him to insert the key and turn the lock on door #3 and to do it in every third door. Then starting with door #4 and every fourth door. This continues the same pattern through all 1000 cell doors. How many prisoners are released and how many are still locked up? Explain your answer.