Skip to content

Instantly share code, notes, and snippets.

@adnan360
Created April 28, 2015 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adnan360/03ba2e5950ba4a148a3e to your computer and use it in GitHub Desktop.
Save adnan360/03ba2e5950ba4a148a3e to your computer and use it in GitHub Desktop.
A script to make virtual coint tosses. You can just give how many coin tosses you want and the script will make that many coin tosses.
-- title
io.write('** COIN TOSS SIMULATOR **\n\n')
-- take input
io.write('Please enter how many coin toss you want:')
num = io.read()
-- tossing
tails=0
heads=0
for i=1,num do
result = math.random(1,2)
if result == 1 then
io.write('head\n')
heads=heads+1
else
io.write('tail\n')
tails=tails+1
end
end
--total
io.write('-------------------------------\n')
io.write('Total result:\n')
io.write('Heads: ',heads,' \tTails; ',tails, '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment