Fix a broken random function
JavaScript - 69 characters

This uses the von Neumann extractor to generate unbiased bits; the general algorithm is also described on the HotBits website. Three bits are used to form a number from 0 to 7. All numbers 5 and above are discarded, and 1 is added to each of the rest before they are printed. I made a simulation to show that this is not heavily biased.

You need to provide your own function r() to access the RNG.

 for(;;v&lt;5&amp;&amp;alert(v+1))for(v=i=0;i&lt;3;a-b&amp;&amp;(v*=2,v+=a&lt;b,i++))b=r(a=r())