Jump to content

Seven-sided dice from five-sided dice: Difference between revisions

m
No edit summary
Line 1,003:
};</lang>
=={{header|Perl}}==
Using dice5 twice to generate numbers in the range 0 to 24. If we consider these modulo 8 and re-call if we get zero, we have eliminated 4 cases and created the necessary number in the range from 1 to 7.
<lang perl>sub dice5 { 1+int rand(5) }
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.