i'm reading a programming book and one of the problems it asks me to solve is to write a program that determines the larger and smaller values of two integers that the user inputs. I could not use if statements in the program.(adsbygoogle = window.adsbygoogle || []).push({});

I checked the answer and they had used this expression to come solve it.

long larger = (a*(a/b) + b*(b/a))/(a/b + b/a);

long smaller = (b*(a/b) + a*(b/a))/(a/b + b/a);

i was wondering how they have gone about finding those expressions? i'm not a math whiz so i was wondering if there was something in my mathematics education that was lacking.

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Reading a programming book

Loading...

Similar Threads for Reading programming book |
---|

I Linear Programming: how to identify conflicting equations |

I Linear mapping of a binary vector based on its decimal value |

I Linear Program:Multiple Optima for multivariable Obj. Func.? |

**Physics Forums | Science Articles, Homework Help, Discussion**