Advertisement
Kodos

cointoss.lua

Jan 9th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.31 KB | None | 0 0
  1. local times = ...
  2.  
  3. local heads = 0
  4. local tails = 0
  5.  
  6. for flips = 1, times do
  7. coin = math.random(1,2) -- Can be increased for more range, just be sure to update the checks
  8. if coin == 1 then
  9. heads = heads + 1
  10. elseif coin == 2 then
  11. tails = tails + 1
  12. end
  13. end
  14.  
  15. print(heads .. " heads and " .. tails .. " tails.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement