Python程序从给定的N个数字中找到最大倍数
生活随笔
收集整理的這篇文章主要介紹了
Python程序从给定的N个数字中找到最大倍数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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 = 0num = 0maxnum = 0x = 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 = numelse:print("Not multiple")n += 1print("The maximum multiple :",maxnum)Output
輸出量
翻譯自: https://www.includehelp.com/python/find-the-maximum-multiple-from-given-n-numbers.aspx
總結
以上是生活随笔為你收集整理的Python程序从给定的N个数字中找到最大倍数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gdb ldexp_带有Python示例
- 下一篇: 使用JavaScript的图像识别游戏