From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1.

2025/03/3100:56:36 technology 1333

From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1. - DayDayNews

cover

2 integers minimum common multiple

In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1.

From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1. - DayDayNews

Example 1

. In version 3.8 and previous versions, the gcd function needs to be used, as shown in the following figure 2.

From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1. - DayDayNews

Example 2

In example 2, a function is defined, and the return value of the function is the minimum common multiple of the variables X and Y. After substituting 6 and 4 into the custom function, the minimum common multiple is 12. It should be noted that if you use "/" in a custom function, you will generate a floating point decimal (flot), so you use the "//" (divided) operator.

html The minimum common multiple of more than 33 integers

In version 3.9, the lcm function also supports the calculation of more than 3 integers. As shown in Figure 3 below.

From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1. - DayDayNews

Example 3

In version 3.8, you need to use the gcd function and customize the function. Example 4 below.

From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1. - DayDayNews

Example 4

List object features minimum common multiple

When you find the minimum common multiple for the features in the list object, you must add "*" before the parameter. As shown in Figure 5,

From Python 3.9, the Math module has added a new function lcm function that calculates the minimum common multiple. In version 3.9, the lcm function can be used to quickly obtain the minimum common multiple of 2 integers, as shown in the following figure 1. - DayDayNews

Example 5

technology Category Latest News

On November 3, the 2022 Yunqi Conference opened in Yunqi Town, Hangzhou. Thousands of major guests, more than 60 science and technology summits and forums, and more than 1,000 new technology products have been released... The Yunqi Conference has attracted much attention from the - DayDayNews

On November 3, the 2022 Yunqi Conference opened in Yunqi Town, Hangzhou. Thousands of major guests, more than 60 science and technology summits and forums, and more than 1,000 new technology products have been released... The Yunqi Conference has attracted much attention from the

Don’t understand low code, just like you don’t know how to use word twenty years ago. Zhang Jianfeng, president of Alibaba Cloud: The changes brought about by cloud computing are greatly underestimated.