Python程序从给定的N个数字中找到最大倍数

本文提供了一种计算效率高的算法,用于从一组5个数字中找到给定数字x的最大倍数。代码实现详述了这一过程,并给出了程序的输出结果。
摘要由CSDN通过智能技术生成

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 mul
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值