fork download
  1. os.execute( "cls" )
  2. print("How many numbers?")
  3. amountNo = io.read "*n"
  4. if amountNo <= 2 then
  5. print "You cant have less than 2 numbers."
  6. elseif amountNo >= 14 then
  7. print "Can't calculate more than 14 numbers."
  8. else
  9. local sum = 0
  10. for i = 1, amountNo do
  11. print( ('Enter number %s'):format(i) )
  12. local nmb = io.read '*n'
  13. sum = sum + nmb
  14. end
  15. print( ('The sum is: %s'):format(sum) )
  16. end
Success #stdin #stdout #stderr 0.02s 5268KB
stdin
6
3
2
5
4
9
7
stdout
How many numbers?
Enter number 1
Enter number 2
Enter number 3
Enter number 4
Enter number 5
Enter number 6
The sum is: 30
stderr
sh: cls: command not found