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

Content added Content deleted
No edit summary
Line 1,003: Line 1,003:
};</lang>
};</lang>
=={{header|Perl}}==
=={{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) }
<lang perl>sub dice5 { 1+int rand(5) }