1. To calculate the greatest common divisor of X and y by division of toss and turn

Toss and turn and divide

Toss and turn division, also known as Euclidean algorithm, is an algorithm to find the greatest common divisor of two positive integers. It is the oldest known algorithm, dating back to 300 BC.

It is done by dividing the larger number by the smaller number, dividing the divisor by the remainder (the first remainder), dividing the first remainder by the remainder (the second remainder), and so on until the final remainder is 0. If you’re taking the greatest common divisor of two numbers, then the final divisor is the greatest common divisor of those two numbers.

The code performance

X = eval(input("x = ")) y = eval(input("y = ")) if x < y: x, y = y, x # R = x % y x = y y = r print("result =", y)Copy the code

The number of different combinations of five yuan, two yuan and one yuan into one hundred yuan

The code performance

Count = 0 for I in range(21): # I belong to [0,1,2,3,4... Print ("count = ", count) print("count = ", count)Copy the code