# 2007 iTest Problems/Problem 44

## Problem

A positive integer $n$ between $1$ and $N=2007^{2007}$ inclusive is selected at random. If $a$ and $b$ are natural numbers such that $a/b$ is the probability that $N$ and $n^3-36n$ are relatively prime, find the value of $a+b$.

## Solution

Factoring $2007^{2007}$ results in $3^{4014} \cdot 223^{2007}$, and factoring $n^3 - 36n$ results in $n(n+6)(n-6)$. In order for $N$ and $n^3 - 36n$ to be relatively prime, then $n^3 - 36n$ can not have multiples of $3$ or $223$, and $n$ can not be $6$ away from a multiple of $223$, so use complementary counting.

There are $\frac{2007^{2007}}{3}$ numbers in the range that are a multiple of $3$, and there are $3 \cdot \frac{2007^{2007}}{223} - 1$ numbers from $1$ to $2007^{2007}$ that are multiples of $223$ or $6$ away from a multiple of $223$. However, there are $3 \cdot \frac{2007^{2007}}{669} - 1$ numbers that are a multiple of $3$ and a multiple of $223$ or six away from a multiple of $223$. Using PIE, there are a total of $\frac{229}{669} \cdot 2007^{2007}$ values of $n$ that do not work.

That means the number of values of $n$ that work is $\frac{440}{669} \cdot 2007^{2007}$, and since a number is picked at random from $2007^{2007}$ values, the probability that $N$ and $n^3 - 36n$ are relatively prime is $\frac{440}{669}$. Thus, $a+b = \boxed{1109}$.