Prove that average of n numbers is greater than equal to the lowest number and less than or equal to the greatest number.
Prove that average of n numbers is greater than equal to the lowest number and less than or equal to the greatest number.
Since this smells of homework I'm not gonna do a full proof and/or proper proof.
Assume you have two numbers A and B which have the average n. So the proof needs to show that
MIN(A,B) <= n <= MAX(A,B)
Now with two numbers you have three situations:
1) A = B
2) A > B
3) A < B
However, we really only need to prove 2 or 3 as it can cover both cases.
1) If A=B then MIN(A,B) = A and MAX(A,B) = A. n = 2A/2 = A. So A <= A <= A is true
2) If A>B then MIN(A,B) = B and MAX(A,B) = A. Additionally: A = B + x, where x > 0. So n = (A + B)/2 = (B + x + B) / 2 = (2B + x)/2 = 2B/2 + x/2 = B + x/2. So we are left with: B <= B + x/2 <= A. B <= B + x/2 -> 0 <= x/2 and since x>0 it is true. B+x/2 <= A -> B + x/2 <= B + x -> x/2 <= x and since x>0 it is true.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.