Here, we will be framing code for finding the maximum multiple of a number x from a given set of a number (set of 5 numbers in this program).
在這里,我們將使用成幀代碼, 從給定的一組數字(此程序中的5個數字組成的集合)中找到x的最大倍數 。
There are many ways of doing this but this time, we have to thought of most computationally efficient algorithm to do so.
有很多方法可以做到這一點,但是這一次,我們必須考慮到計算效率最高的算法。
Following is the code for such problem,
以下是解決此問題的代碼,
n = 0
num = 0
maxnum = 0
x = int(input("Enter the num of which you want to find highest multiple: "))
while n<5:
num = int(input("Enter your number : "))
if num%x == 0:
if num > maxnum:
maxnum = num
else:
print("Not multiple")
n += 1
print("The maximum multiple :",maxnum)
Output
輸出量

翻譯自: https://www.includehelp.com/python/find-the-maximum-multiple-from-given-n-numbers.aspx