P.J. starts with and chooses a positive integer with . He applies the following algorithm to and : P.J. sets equal to the remainder when is divided by . If , P.J. sets . If , P.J. sets equal to the remainder when is divided by . If , P.J. sets . If , P.J. sets equal to the remainder when is divided by . For how many of the positive integers with does P.J.'s algorithm give and and ?
Solution
Suppose that and and and and . Since , then the algorithm says that is the remainder when is divided by . Since , then is a multiple of . Thus, for some positive integer . Since , then the algorithm says that is the remainder when is divided by . In other words, for some positive integer . But , so . In other words, is a multiple of , say for some positive integer . Since , then is the remainder when is divided by . In other words, for some positive integer . But and so . In other words, is a multiple of , say for some positive integer . But and . Since is a multiple of , then is a divisor of 500 and so the possible values of are . (None of is a divisor of 500.) We know that is a multiple of , that (because is the remainder when is divided by ), and that . If , then or . If , then or . If , then . Suppose that and . Since , then and so . Therefore, is a divisor of 490, is a multiple of 5 (because ), must be greater than , and must be 5 more than a multiple of 10 (because the remainder when is divided by is ). Since , then the divisors of 490 that are multiples of 5 are (these are 5 times the divisors of ). Among these, those greater than having remainder 5 when divided by 10 are 35 and 245, and so the possible values of in this case are 35 and 245. For each possible pair and , we determine the values of that satisfy the following conditions: - is a divsior of , - is a multiple of , - is greater than , and - the remainder when is divided by is . Therefore, the possible values of are , of which there are 13.