Py|| Friendly number

题目描述
There are two integers a snd b. If the sum of b’s divisors equals to a, and the sum of a’s divisors equals to b, we call these two integers are “Friendly numbers”.

E.g:

  1. 9 and 4
    The sum of 9’s divisors is: 1 + 3 = 4
    The sum of 4s divisors is: 1 + 2 = 3
    So 9 and 4 are not Friendly numbers.

  2. 284 and 220
    The sum of 220’s divisors is: 1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110=284
    The sum of 284’s divisors is: 1 + 2 + 4 + 71 + 142=220

So 220 and 284 are Friendly numbers.

Write a program to determine if the two numbers are friendly numbers.

输入
Two integers, separated by spaces. (Two integers are less than 10000)
输出
If it is a friendly number, output “yes”, otherwise output “no”, note that no quotes are included.
样例输入 Copy
220 284
样例输出 Copy
yes

a,b=map(int,input().split())
s1=0
s2=0
for i in range(1,a):
    if a%i==0:
        s1=s1+i
for i in range(1,b):
    if b%i==0:
        s2=s2+i
if s1==b and s2==a:
    print('yes')
else:
    print('no')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值