4

I want to use gcd function of the Integer class. Using the example from Ruby Doc as a test it fails:

irb(main):001:0> 72.gcd 168
NoMethodError: undefined method `gcd' for 72:Fixnum
        from (irb):1

I have the windows one click installer ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]. On other PCs with the same version of ruby this works correctly.

Any ideas?

Gerhard
  • 6,850
  • 8
  • 51
  • 81

2 Answers2

2

Try

require 'rubygems'
72.gcd 168
nas
  • 3,676
  • 19
  • 19
2

require 'rational'

Brandon
  • 21
  • 1