Not inspired, but pulled from 2004 minicourse

fcf_to_cv=:2&x:@:((+%)/\)@:x:
fcf_to_r=:%/@:{:@:fcf_to_cv :. r_to_fcf
r_to_fcf=:3 : 0
'r0 r1'=.2 x: y
z=.i.0
while. r1~:0 do.
   q=.<.r0%r1
   z=.z,q
   'r0 r1'=.r1,r0-q*r1
end.
z
)
fcf_to_r 1 2 3 4 5 2 1
r_to_fcf 15r4

mcf=:*&.fcf_to_r

1 2 3 4 mcf 1 1 2 1 1


Henry Rich wrote:
> Does anyone have J code for multiplying two numbers expressed as simple 
> continued fractions, producing a continued-fraction result?
> 
> Henry Rich
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 

-- 
Clifford A. Reiter
Mathematics Department, Lafayette College
Easton, PA 18042 USA,   610-330-5277
http://www.lafayette.edu/~reiterc
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to