JRS: In article <1137117147.708779.271350@g14g2000cwa.googlegroups .com>
, dated Thu, 12 Jan 2006 17:52:27 local, seen in
news:comp.lang.javascript,
mouseit101@gmail.com <mouseit101@gmail.com>
posted :[color=blue]
>Does anybody have a script to simplify fractions?[/color]
Let the fraction be X/Y, X & Y being variables.
function HCF(u, v) { var U = u, V = v
while (true) {
if (!(U%=V)) return V
if (!(V%=U)) return U } }
T = HCF(X, Y) ; X /= T ; Y /= T ;
HCF is used in js-dates.htm, via FAQ, see below. It is intended for use
only with positive integer parameters, but full compliance is not
obligatory.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.