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