Given two scalars that contain non-negative integer values, as ($numerator, $denominator). $denominator is non-zero as well.
Find the perl golf solution subroutine that returns the reduced fraction; that is, a fraction that is still equivalent to the initial fraction but using the smaller possible (non-negative!) integer values to make it up. The fraction is returned as an array in the order of (numerator, denominator).
Examples can include:Thanks to tilly for the update.@a = reduce( 512, 1024 ); # @a = ( 1, 2 ) @a = reduce( 12, 18 ); # @a = ( 2, 3 ) @a = reduce( 1, 7 ); # @a = ( 1, 7 )
-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
Back to
Meditations