e$B;EMM$r3NG’$7$F$$$-$?$$$H;W$$$^$9!#e(B
Rational.new!e$B!"e(BRational.newe$B!"e(BRational.reducee$B!"e(BRational()
e$B$K$D$$$Fe(B
Rational.new! 1e$B$D$+e(B2e$B$D$N0z?t$r<h$k!#e(B
e$B0l@Z$N%A%’%C%/$J$7!#e(B
e$B0z?t$,@0?t$G$J$$>l9ge(B to_i e$B$5$l$k!#e(B
reduce e$B$J$7!"e(Bunify e$B$J$7!#e(B
e$B@PDM$5$s$N$Oe(B den
e$B$,Ii$N$H$-$ND4@0$r$9$k$,!“86$5$s$N$O$7$J$$!#e(B
ishi> Rational.new!(1,1.3) #=> Rational(1,1)
hara> Rational.new!(1,1.3) #=> Rational(1,1.3)
e$B86$5$s$N$O$^$k$C$-$j$=$N$^$^$G$”$k!#e(B
e$B86$5$s$N$OI,$:0z?t$,e(B2e$B$D$G$J$1$l$P$J$i$J$$!#e(B
Rational.new e$B$O!“e(B1e$B$D$+e(B2e$B$D$N@0?t$N0z?t$r<h$k!#e(B
1e$B$DL$N0z?t$,e(B Rational e$B$Ge(B 2e$B$DL$,e(B 1
e$B$N>l9g$r5v$9!#e(B
reduce e$B$”$j!“e(Bunify e$B$”$j!#e(B
e$B86$5$s$N$O$I$A$i$N0z?t$b@0?t$G$J$$$H$J$i$J$$!#e(B
e$B86$5$s$N$Oe(B reduce e$B$HF1$8$G$"$k!#e(B
e$B@PDM$5$s$N$K$Oe(B new e$B$OB8:_$7$J$$!#e(B
Rational.reduce e$B$O!“e(B1e$B$D$+e(B2e$B$D$N@0?t$N0z?t$r<h$k!#e(B
reduce e$B$”$j!“e(Bunify e$B$”$j!#e(B
e$B86$5$s$N$Oe(B new e$B$HF1$8$G$"$k!#e(B
Rational() e$B$O!"e(B1e$B$D$+e(B2e$B$D$N0z?t$r$H$k!#e(B
e$B$I$A$i$N0z?t$b@0?t!"IbF0>.?tE@?t!“M-M}?t!“J8;zNs$G$”$C$F$h$$!#e(B
reduce e$B$”$j!“e(Bunify e$B$”$j!#e(B
e$B86$5$s$N$O!"J8;zNs$O$R$H$D$G$J$1$l$P$J$i$J$$!#e(B
new e$B$Oe(B reduce e$B$HF1$8$G$$$$$+$b$7$l$^$;$s!#e(B
new e$B$Ge(B Rational
e$B$r:FF~NO$G$-$k$N$O$$$$$N$+$I$&$+!"$h$/$o$+$j$^$;$s!#JXe(B
e$BMx$G$"$k$+$b$7$l$J$$$1$I!"$=$&$$$&$3$H$Oe(B Rational()
e$B$G=PMh$k$7!“e(Bnew e$B$Ge(B
e$B$O!“CF$$$F$”$2$?$[$&$,?F@Z$G$”$k$H9M$($k$3$H$b$G$-$^$9!#e(B
e$B$=$b$=$be(B new! e$B$He(B reduce e$B$OI,MW$J$N$+!#e(B
ruby e$B$G=q$/$He(B new! e$B$N$h$&$J$b$N$,I,MW$K$J$j$^$9$,!“e(BC
e$B$G=q$-D>$7$?$b$Ne(B
e$B$G!“0UL#$,$”$k$+$O$h$/$o$+$j$^$;$s!#>C$9$N$O$$$D$G$b=PMh$k$N$G!”:#$O;De(B
e$B$7$F$"$j$^$9!#e(B
reduce e$B$N0U5A$,$h$/$o$+$j$^$;$s!#86$5$s$N$G$Oe(B new
e$B$HF1$8$G$9$,!"e(Bnew e$B$Ne(B
e$BJLL>$H9M$($F$bHyL/$G$9!#e(B
e$B$I$&$7$F$b!"e(BRational.new!(*Rational.reduce(n,d)) e$B$H$+e(B
Rational.reduce(Rational.new!(n,d))
e$B$N$h$&$J$b$N$rA[A|$7$F$7$^$$$^$9!#e(B
new! e$B$He(B reduce
e$B$O!“7Y9p$7$F!”>-MhL58z$K$7$?$[$&$,$$$$$+$b$7$l$^$;$s!#e(B