Enter two numbers and find the least common multiple (for loop/function method)

Method 1: for loop

 Method 2: for loop condition, writing (function method)

 

The condition is being written, the effect without a break is as follows, the smallest is first, so it is necessary to add a break to terminate

 

Method 3: for loop condition, write backwards (function method)

 

Invert the output effect, assuming min = 10, max = 15, the least common multiple is at the end, the value is 30, so you need to declare a min = 0, then reassign, and finally output 30

 

 

 

 

Guess you like

Origin blog.csdn.net/m0_67859656/article/details/127797825