- #1
gerald
- 13
- 0
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.
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.
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.