Let $\frac mn$ be a fraction, where $m$ and $n$ are positive integers. Consider the operation defined by replacing $\frac mn$ by $\frac{m+1}{n+1}$ and then writing the result in lowest terms. For example, applying this operation to $\frac{5}{14}$ would give $\frac{2}{5}.$ How many times must this operation be repeatedly applied to $\frac{1}{2005}$ before we obtain $\frac{2004}{2005}?$
How many ordered pairs of positive integers $(m,n)$ satisfy $\text{GCD}(m,n) = 3$ and $\text{LCM}(m,n) = 108?$
p=0;print 1/1005;print 1/1003;print 1/502;print 2/503;a=1;b=168;cycle1:c=a/b;printc;p=p+1;a++;b++;if(a<167, goto cycle1, 0);a=1;b=2;cycle:c=a/b;printc;p=p+1;a++;b++;if(a<2005, goto cycle,0);printp+4
1 / 1005
1 / 1003
1 / 502
2 / 503
1 / 168
2 / 169
3 / 170
This continues until you get: 166 / 333 + 1
165 / 332
166 / 333
1 / 2
2 / 3
3 / 4 - This continues until you get: 2004 / 2005
2001 / 2002
2002 / 2003
2003 / 2004
2004 / 2005
TOTAL TERMS = 2,174