Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@SherlockHolmes3 | 447 |

@codeantik | 446 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. Given two Numbers **A **and **B**, find whether they are Amicable Numbers or not. Print 1 if they are Amicable else 0.

**Example 1:**

Input:A= 220 ,B= 284Output:1Explanation:Proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110. Sum of these is 284. Proper divisors of 284 are 1, 2, 4, 71 and 142 with sum 220.

**Example 2:**

Input:A= 4 ,B= 8Output:0Explanation:Proper divisors of 4 are 1 and 2. Sum of these is 3!=8. Proper divisors of 8 are 1, 2 and 4 with sum 7!=4 and thus the Otput 0.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **isAmicable()** which takes 2 Integes A and B as input and returns the answer.

**Expected Time Complexity:** O(sqrt(A,B))

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 <= A,B <= 10^{5}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Amicable Pair

...