Answer to Question #198775 in Python for Ravi

Question #198775

Lucky Pairs

Two numbers are said to be lucky pairs . if first number is divided by second number and second number is divided by first number. given an integer N . find all possible combinations of lucky pairs.



input:

2


output:

2


Explanation:

input is 2

possible combinations are [1,2],[2,1].here in [1,2]1 is divisible by 2, and in [2,1] 2 is divisible by 1 .so the number of lucky pairs are 2.



1
Expert's answer
2021-05-26T13:49:10-0400
n=int(input())
count=0
for i in range(1,n+1):
    for j in range(1,n+1):
        if i!=j and i%j==0:
            count+=1
print(2*count)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS