1

If I enter: 1/RandomInteger[10^200]+1/RandomInteger[10^200] I get (instantly) an exact fraction. Is this fraction in simplified (reduced) form? In other words is the greatest common divisor of the numerator and denominator equal to 1?.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Geoffrey Critzer
  • 1,661
  • 1
  • 11
  • 14
  • Yes. (And what does the reference to RandomInteger have to do with the fundamental question anyway?) – David G. Stork Mar 18 '15 at 13:12
  • The function RandomInteger has nothing to do with my question. My question is how does Mathematica simplify a fraction so quickly. I thought simplifying the fraction would necessitate factoring the integers. – Geoffrey Critzer Mar 18 '15 at 13:39
  • I strongly recommend you change your question title (which isn't a question anyway) to be relate to your actual question. Future users will be very confused by your irrelevant reference to RandomInteger. – David G. Stork Mar 18 '15 at 13:42
  • Now that I have thought better about it I see that we do not need to factor the integers (numerator and denominator) in order to simplify a fraction. – Geoffrey Critzer Mar 18 '15 at 13:51
  • 2
    It is not necessary to factor the integers. Euclidean algorithm can computer the greatest common factor, then both the numerator and denominator divide the gcd. All the operations is only the division. – Ukiyo-E Mar 18 '15 at 13:53
  • 2
    Note that if you would like it not to reduce the Rational, you can use Internal`RationalNoReduce (e.g. Internal`RationalNoReduce[2, 4]). The lack of reduction is persistent. – Dan Fortunato Mar 18 '15 at 15:59

1 Answers1

3

The answer is yes, and you can also test it.

1/RandomInteger[10^200] + 1/RandomInteger[10^200] /. 
 Rational[a_, b_] :> GCD[a, b]
1
Ukiyo-E
  • 259
  • 1
  • 4