Problem 2162. Let's get back to school: create mixed numbered fraction

A fractional number can be represented as mixed number.

A "mixed number" consists of an integer followed by a proper fraction and "proper fraction" is a fraction with the numerator smaller than the denominator.

e.g. if given fraction is, 1.33 then, it can be represented as 1 (1/3), meaning, (1*3+1)/3 = 4/3 = 1.33

The task is to convert the given fractional number into a mixed number and return the 3 digits as an array of length 3. For making it easy and to output unique solution, the integer should always be 1 and the remaining fraction need not be a "proper fraction". (so for input 1.33, output will be [1 1 3], for input 1.66, output will be [1 2 3] )

Solution Stats

42.31% Correct | 57.69% Incorrect
Last solution submitted on Apr 29, 2017

Problem Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!