python求最大公约数,python程序打包,python求完数

版权声明:原创 https://blog.csdn.net/qq_41058594/article/details/82666584

*求最大公约数

def gcd(x,y):
    if x < y:
        x,y = y,x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y
a = eval(input(""))
b = eval(input(""))
gcdab = gcd(a,b)
print("{}与{}的最大公约数是{}".format(a,b,gcd(a,b)))

PyInstaller 库可以对程序打包,给定一个 Python 源程序文件 a.py,图标文件为 a.ico,将其打包为在 Windows 平台上带有上述图标的单一可执行文件

pyinstaller –i a.ico –F a.py

某自然数除它本身之外的所有因子之和等于该数,则该数被称为完数。请输出1000以内的完数

for i in range(2,1001):
    s = i
    for j in range(1,i):
        if i%j == 0:
            s -= j
    if s == 0:
        print(i)

猜你喜欢

转载自blog.csdn.net/qq_41058594/article/details/82666584
今日推荐