Average of n numbers

This is a discussion on Average of n numbers within the Tech Board forums, part of the Community Boards category; Prove that average of n numbers is greater than equal to the lowest number and less than or equal to ...

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    Average of n numbers

    Prove that average of n numbers is greater than equal to the lowest number and less than or equal to the greatest number.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    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.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 06:20 AM
  2. 3x syntax errors :S, Help a student finalise an assignment
    By Chickenhawk in forum C Programming
    Replies: 14
    Last Post: 07-27-2006, 06:14 AM
  3. I have a function and I need multiple averages returned
    By tommy69 in forum C++ Programming
    Replies: 20
    Last Post: 04-13-2004, 12:45 PM
  4. Min/Max Numbers
    By mzt in forum C++ Programming
    Replies: 1
    Last Post: 03-05-2004, 07:20 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21