Project Euler

Problem #243

A positive fraction whose numerator is less than its denominator is called a proper fraction.
For any denominator, d, there will be d−1 proper fractions; for example, with d = 12:
^(1)/_(12) , ^(2)/_(12) , ^(3)/_(12) , ^(4)/_(12) , ^(5)/_(12) , ^(6)/_(12) , ^(7)/_(12) , ^(8)/_(12) , ^(9)/_(12) , ^(10)/_(12) , ^(11)/_(12) .

We shall call a fraction that cannot be cancelled down a resilient fraction.
Furthermore we shall define the resilience of a denominator, R(d), to be the ratio of its proper fractions that are resilient; for example, R(12) = ^(4)/_(11) .
In fact, d = 12 is the smallest denominator having a resilience R(d) < ^(4)/_(10) .

Find the smallest denominator d, having a resilience R(d) < ^(15499)/_(94744) .