fmod()
Published Oct 26, 2023
Contribute to Docs
The method fmod()
takes two numbers and returns the remainder of the first number divided by the second number.
Syntax
The syntax of fmod()
is as follows:
math.fmod(num1, num2)
Where num1
is the value to be divided by num2
.
Examples
The following examples illustrate the behavior of fmod()
:
print(math.fmod(6, 4))print(math.fmod(4, 6))print(math.fmod(12, 4))print(math.fmod(8.04829, 1))print(math.fmod(4.63, 2.89))print(math.fmod(0, 9))
This results in the output:
2400.048291.740
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