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 | 1083 |

@bt8816103042 | 739 |

@SherlockHolmes3 | 444 |

@SHOAIBVIJAPURE | 430 |

@codeantik | 429 |

@shalinibhataniya1097 | 400 |

@ShamaKhan1 | 392 |

@neverevergiveup | 372 |

@amrutakashikar2 | 355 |

@murarry3625 | 350 |

@mahlawatep | 349 |

Complete Leaderboard |

Given two integer numbers a and b, the task is to find count of all common divisors of given numbers.

**Example 1:**

Input: a = 12, b = 24Output:6Explanation: all common divisors are 1, 2, 3, 4, 6 and 12.

**Example 2:**

Input:a = 3, b = 17Output:1Explanation: all common divisors are 1.

**Your Task: **

You dont need to read input or print anything. Complete the function **commDiv() **which takes n as input parameter and returns the number of common divisors.

**Expected Time Complexity:** O(sqrt(n))

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

**Constraints:**

1<= a,b <=1000

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
Common Divisors

...