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**

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

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