# Integer (Class)

In: | rational.rb
Parent: | Object

## Methods

denominator gcd gcd2 gcdlcm lcm numerator to_r

## Public Instance methods

numerator()

[Source]

    # File rational.rb, line 270
      def numerator
        self
      end

denominator()

[Source]

    # File rational.rb, line 274
      def denominator
        1
      end

to_r()

[Source]

    # File rational.rb, line 278
      def to_r
        Rational(self, 1)
      end

gcd(n)

[Source]

    # File rational.rb, line 282
      def gcd(n)
        m = self.abs
        n = n.abs

        return n if m == 0
        return m if n == 0

        b = 0
        while n[0] == 0 && m[0] == 0
          b += 1; n >>= 1; m >>= 1
        end
        m >>= 1 while m[0] == 0
        n >>= 1 while n[0] == 0
        while m != n
          m, n = n, m if n > m
          m -= n; m >>= 1 while m[0] == 0
        end
        m << b
      end

gcd2(int)

[Source]

    # File rational.rb, line 302
      def gcd2(int)
        a = self.abs
        b = int.abs

        a, b = b, a if a < b

        while b != 0
          void, a = a.divmod(b)
          a, b = b, a
        end
        return a
      end

lcm(int)

[Source]

    # File rational.rb, line 315
      def lcm(int)
        a = self.abs
        b = int.abs
        gcd = a.gcd(b)
        (a.div(gcd)) * b
      end

gcdlcm(int)

[Source]

    # File rational.rb, line 322
      def gcdlcm(int)
        a = self.abs
        b = int.abs
        gcd = a.gcd(b)
        return gcd, (a.div(gcd)) * b
      end

[Validate]