2
$\begingroup$

Came across this math problem while programming something:

Given positive $y$, $a$, and $b$, find an integer $x$, $a\lt x\lt b$, so that $y\bmod x$ (the remainder of $y$ when divided by $x$) is positive and less than or equal to $100$, $$0 \lt y\bmod x \leq 100.$$

I know sometimes it's not solvable depending on $y$ and the range. I'm not really sure where to begin because I wasn't very good at modular algebra.

I really don't want to have to try every possible number for $x$ between $a$ and $b$ because the range I'm using it for has over 25 million in length.

Edit: Sorry the question wasn't very clear. $y$, $a$, and $b$ are given. And I'm trying to find an $x$ that satisfies those conditions.

Edit 2: I've realize $y \bmod x$ need to be less than or equal to $100$ and also over $0$.

  • 3
    What's the actual question?2010-11-26
  • 0
    Is the question: find $x\in[a,b]$ such that $y \mod x \le 100$ ?2010-11-26

2 Answers 2