Module:Shared: Difference between revisions

Added a fraction function
(Added GCD function)
(Added a fraction function)
Line 289: Line 289:
     end
     end
   end
   end
end
--Formats a pair of numbers as a reduced fraction
function p.fraction(n, d)
  local gcd = p.gcd(n, d)
  return p.formatnum(n/gcd)..'/'..p.formatnum(d/gcd)
end
end
   
   
return p
return p