On Jul 25, 2007, at 5:29 PM, Kaldrenon wrote:

> My full script is now:
>
> p Time.now
> require 'mathn'
> red_prop_fract = 0
> for d in 2..10_000 do
>   for n in 1...d do
>     if n.to_f/d > 1.0/3 && n.to_f/d < 0.5 && n.gcd2(d) == 1
>       red_prop_fract += 1
>     end
>   end
> end
>
> p red_prop_fract.length
> p Time.now

That's very close to what I did. However, the conditional clause of  
the if-statement can be improved a little:

     if 3 * n > d && 2 * n < d && n.gcd(d) == 1

Staying with integers is faster, and gcd is a little faster than gcd2.

Regards, Morton