Find the minimum of two numbers

Task. Were given two real numbers [latex]x[/latex] and [latex]y[/latex]. Find [latex]\min (x, y)[/latex].

Tests

Input Output
758 843 Maximum number is: 843
459 238 Maximum number is: 459

Solution

With if-statement

Code refactoring

Without if-statement

 

Find the minimum of three numbers

Task. Were given three real numbers [latex]x[/latex], [latex]y[/latex], [latex]z[/latex]. Find [latex]\min (x, y, z)[/latex].

Tests

Input Output
7 8 9  7
8771 1346574 1131  1131

Solution

With if-statement

Code refactoring