Coding challenge

There are two math functions, math.ceil(x) and math.floor(x). math.ceil() finds the next integer larger than x and math.floor(x) find the next integer smaller than x.

Write some code that reads a number from the keyboard, using a line like x=input(). Then, using the math.ceil() and math.floor() functions, properly round the number (in x) to the nearest integer. So 4.5 should round to 5 and 4.3 should round to 4, etc. Your code should display the rounded number to the screen using print.

You might have to experiment with math.ceil(x) and math.floor(x) a bit first. Try, for example print(math.ceil(5.3)) or print(math.floor(5.3)). In your math book, these will be called the "greatest" and "least" integer functions.

Type your code here:

Lua reference

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code: