min()
Published Oct 13, 2023Updated Oct 28, 2023
Contribute to Docs
In Lua, the math.min()
function is used to return the smallest value from a series of one or more numbers.
Syntax
math.min(values)
values
(required): The series of numbers to return the smallest value from. These numbers can be positive or negative. The function also takes variable names assigned to values rather than the values themselves.
Example
In the following example, the math.min()
method is called twice. The first call gives the numbers directly to the function. The second call uses the variable names assigned to the values instead of the values themselves.
v = 1a = 4l = 7print(math.min(2, 6, 10))print(math.min(v, a, l))
This will result in the following output:
21
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Lua on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Lua
Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.Beginner Friendly4 hours