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.
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)
Comments
Leave a comment