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

Content added Content deleted
(→‎{{header|C}}: reduced operator set version)
Line 348: Line 348:
6 142648
6 142648
7 142619 </pre>
7 142619 </pre>

=={{header|Lua}}==

<lang lua>dice5 = function() return math.random(5) end

function dice7()
x = dice5() * 5 + dice5() - 6
if x > 21 then return dice7() end
return x%7 + 1
end</lang>


=={{header|OCaml}}==
=={{header|OCaml}}==