Counting Pairs Problem Statement

Given a positive integer N, determine the count of all possible positive integral pairs (X, Y) that satisfy the equation 1/X + 1/Y = 1/N.

Example:

Input:
T = 1
N = 2
Output:
3
Explanation:

The solutions for 1/X + 1/Y = 1/2 are (3, 6), (6, 3), (4, 4). Total count is 3.

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ N ≤ 104
  • Time Limit: 1 sec.
Input Format:
The first line contains an integer 'T' which represents the number of test cases.
Each test case consists of a single positive integer 'N'.
Output Format:
Each test case output should be an integer denoting the count of the pairs satisfying the equation.
Print the result for each test case on a new line.
Note:
Implement the function to determine the count of pairs. No need to handle input/output formatting manually.
AnswerBot
4mo

Count the number of positive integral pairs (X, Y) that satisfy the given equation.

  • Iterate through all possible values of X and calculate corresponding Y to check if the equation is satisfied.

  • Optimize...read more

Help your peers!
Select
Add answer anonymously...

Goldman Sachs Software Developer Intern interview questions & answers

A Software Developer Intern was asked 5mo agoQ. Write the code for Merge Sort.
A Software Developer Intern was asked Q. Rectangle Area Problem Statement You are provided with a list of rectangles, eac...read more
A Software Developer Intern was asked Q. First Non-Repeating Character Problem Statement You are given a string consistin...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked 6mo agoQ1. Write the code for Merge Sort.
A Software Developer Intern was asked Q2. Rectangle Area Problem Statement You are provided with a list of rectangles, eac...read more
A Software Developer Intern was asked Q3. First Non-Repeating Character Problem Statement You are given a string consistin...read more
Goldman Sachs Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits