Skip to content

第6课最大公因数,最小公倍数有点小问题 #45

Open
@heqiang233

Description

@heqiang233

没有考虑x,y的大小,建议修改一下
x = int(input('x = '))
y = int(input('y = '))
if x > y:
x, y = y, x
for factor in range(x, 0, -1):
if x % factor == 0 and y % factor == 0:
print(f'{x}和{y}的最大公约数是{factor}')
print(f'{x}和{y}的最小公倍数是{x * y // factor}')
break

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions