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

Content added Content deleted
Line 1,342: Line 1,342:
=={{header|Phix}}==
=={{header|Phix}}==
replace rand7() in [[Verify_distribution_uniformity/Naive#Phix]] with:
replace rand7() in [[Verify_distribution_uniformity/Naive#Phix]] with:
<lang Phix>function rand5()
<lang Phix>function dice5()
return rand(5)
return rand(5)
end function
end function


function rand7()
function dice7()
while true do
while true do
integer r = rand5()*5+rand(5)-3 -- ( ie 3..27, but )
integer r = dice5()*5+dice5()-3 -- ( ie 3..27, but )
if r<24 then return floor(r/3) end if -- (only 3..23 useful)
if r<24 then return floor(r/3) end if -- (only 3..23 useful)
end while
end while