# math.min() function in Lua

LuaServer Side ProgrammingProgramming

There are several occurrences when we want to get the min value from a given series of numbers and then use that value later on.

The Minimum value from the series of different numbers is the value that is the minimum of all the numbers that are present in that series.

Lua provides us with a math.min() function that we can use to find the min value out of different numbers that we pass to it as an argument.

## Example

Let’s consider a simple example where we will make use of the math.min() function in Lua −

Live Demo

a = 10
b = 11
c = 12
print(math.min(a,b,c))

## Output

10

It should be noted that if we try to pass the same numbers to the math.min() function then the output will be the same number itself.

## Example

Consider the example shown below −

Live Demo

d = 11
e = 11
print(math.min(a,b))

## Output

11

We can also pass negative numbers in the math.min() function as an argument.

## Example

Consider the example shown below −

Live Demo

f = -10
g = -5
print(math.min(f,g))

## Output

-10
Updated on 19-Jul-2021 11:56:18