PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Count integer pairs satisfying 1/x + 1/y = 1/N

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of number theory and algorithmic problem-solving, focusing on Diophantine equation manipulation, divisor counting, and translating algebraic constraints into combinatorial counts.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Count integer pairs satisfying 1/x + 1/y = 1/N

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

You are given a positive integer `N` (\(1 \le N \le 10^6\)). Consider the Diophantine equation: \[ \frac{1}{x} + \frac{1}{y} = \frac{1}{N}, \] where `x` and `y` are positive integers. Determine **how many ordered pairs** of positive integers `(x, y)` satisfy this equation. Formally, count the number of pairs `(x, y)` with `x > 0`, `y > 0`, and \[ \frac{1}{x} + \frac{1}{y} = \frac{1}{N}. \] Output this count for the given `N`. Your algorithm should be efficient enough to handle values up to `N = 10^6`.

Quick Answer: This question evaluates understanding of number theory and algorithmic problem-solving, focusing on Diophantine equation manipulation, divisor counting, and translating algebraic constraints into combinatorial counts.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Nov 17, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
4
0

You are given a positive integer N (1≤N≤1061 \le N \le 10^61≤N≤106). Consider the Diophantine equation:

1x+1y=1N,\frac{1}{x} + \frac{1}{y} = \frac{1}{N},x1​+y1​=N1​,

where x and y are positive integers.

Determine how many ordered pairs of positive integers (x, y) satisfy this equation.

Formally, count the number of pairs (x, y) with x > 0, y > 0, and

1x+1y=1N.\frac{1}{x} + \frac{1}{y} = \frac{1}{N}.x1​+y1​=N1​.

Output this count for the given N.

Your algorithm should be efficient enough to handle values up to N = 10^6.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Software Engineer•Microsoft Software Engineer•Microsoft Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.