Time is divided into 20-day segments.
Each prisoner is assigned a day of the 20 (ex: one prisoner might be day 3), which everyone else memorizes.
Each time a prisoner enters the bathroom, if it is on his day, he leaves the light on.
Now, the next prisoner will know that that particular prisoner has been to the bathroom.
Once a prisoner knows that another prisoner has been to the bathroom, he can now leave the light on that prisoner's day too to tell others that that prisoner has been to the bathroom.
Ex:
On day 3, [3] is chosen and so he leaves the light on.
On day 4, [12] is chosen, so he doesn't leave the light on.
On the next sequence of 20 days, on day 3 (day 23), the light will be left on if either prisoner [3] or [12] is chosen.
And on the next sequence of 20 days, on day 3 (day 43), prisoners [3], [12], and whoever was chosen on day [4] the last month may leave the light on.
It would get off to a slow start, and I haven't done the math, but the knowledge would build up until eventually someone should get it.