If they've never been in the room they switch the light bulb.
If they've been in the room before then they don't touch the switch.
so... it goes for a long time of switching and no switching until finally when one of the prisoners has been taken to the room say... 100 times where it has been in the same position. then it's a pretty good guess for him to say that everyone has gone. and the higher the number the higher chance that the're right. so even though it would take longer say 500.
Here is an example with ten people and random.org (...= nothing and ...(number)=nothing but they add 1 to their count)
P7 turn on
P9 turn off
P5 turn on
P8 turn off
P6 turn on
P1 turn off
P2 turn on
P6 ...1
P1 ...
P1 ...
P2 ...1
P1 ...
P6 ...2
P8 ...
P1 ...
P1 ...
P7 ...1
...And so on until somebody gets to the number they agreed on would be accurate enough.