Results 1 to 9 of 9

Math Help - six digit numbers...

  1. #1
    Member
    Joined
    Feb 2010
    From
    in the 4th dimension....
    Posts
    122
    Thanks
    9

    Question six digit numbers...

    How many six digit numbers can be produced, such that the sum of the first three digit is equal to the sum of the last three digits ?????

    HELP!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Quote Originally Posted by earthboy View Post
    How many six digit numbers can be produced, such that the sum of the first three digit is equal to the sum of the last three digits ?????

    HELP!
    Are leading zeroes allowed?

    Edit: Also are you required to do this with paper and pencil? Because writing a computer program would be easy, with or without leading zeroes allowed.
    Last edited by undefined; September 15th 2010 at 12:10 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,561
    Thanks
    785
    When I was a kid, we had six-digit bus tickets (leading zeros were allowed). A ticket was considered "lucky" if the sum of the first three digit is equal to the sum of the last three digits. I'd like to know what the probability of getting a lucky ticket is!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    Feb 2010
    From
    in the 4th dimension....
    Posts
    122
    Thanks
    9
    Are leading zeroes allowed?
    nope!leading zero's are not allowed.
    Is repetition of digits allowed?
    yeah! it is allowed
    Also are you required to do this with paper and pencil? Because writing a computer program would be easy, with or without leading zeroes allowed.
    yeah...i need to do on paper.....
    but you can post the computer program too
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Straightforward Java implementation, used [ PHP][/ PHP] tags for colors

    [php]
    public class D2010_09_15_LuckyTickets {
    public static void main(String[] args) {
    long t = time();
    int c = 0, i;
    for (i = 0; i < 1000000; i++) {
    if (isLucky(i)) c++;
    }
    System.out.println(c);
    System.out.println("Elapsed: " + (time() - t) / 1000.0 + " seconds");
    }

    static boolean isLucky(int n) {
    // assume 0 <= n < 10^6
    int a, b;
    String s = Integer.toString(n);
    s = addLeadingZeroes(s, 6);
    a = Integer.parseInt(s.substring(0, 3));
    b = Integer.parseInt(s.substring(3));
    return sd(a) == sd(b);
    }

    static int sd(int n) {
    // return sum of digits of non-negative integer n
    int sum = 0;
    while (n > 0) {
    sum += n % 10;
    n /= 10;
    }
    return sum;
    }

    static String addLeadingZeroes(String s, int len) {
    if (s.length() >= len) return s;
    return addLeadingZeroes("0" + s, len);
    }

    static long time() {
    return System.currentTimeMillis();
    }
    }

    [/php]Output:

    Code:
    55252
    Elapsed: 0.291 seconds
    In order to disallow leading zeroes, all you have to do is change the initializer expression in the for loop in main(). Output for that is

    Code:
    50412
    Elapsed: 0.219 seconds
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    Quote Originally Posted by earthboy View Post
    yeah...i need to do on paper.....
    For paper solution, I can think of a long way for now.

    For three digits here (no leading zeroes), smallest sum is 1, largest sum is 9+9+9=27.

    Simply go through each.

    Count permutations, list digits in ascending order to avoid duplicate counting, and be careful to disallow leading zeroes for the left side.

    For example, handle the sum 5 by

    {0,0,5} -- 3 permutations, but for left side only 1
    {0,1,4} -- 3! permutations, but for left side 2 * 2!
    {0,2,3} -- 3! permutations, but for left side 2 * 2!
    {1,1,3} -- 3 permutations
    {1,2,2} -- 3 permutations

    So you get (1 + 2*2! + 2*2! + 3 + 3) * (3 + 3! + 3! + 3 + 3) = 315.
    Last edited by undefined; September 15th 2010 at 07:05 AM. Reason: fixed error
    Follow Math Help Forum on Facebook and Google+

  7. #7
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    I think a better paper approach can be obtained like this, I'll give a sketch.

    f(n, m) = How many ways to get digit sum n for an m-digit number, leading zeroes allowed.

    Notice \displaystyle f(5, 3) = \sum_{k=0}^5 f(k,2). To disallow leading zeroes, change upper limit to 4.

    I'll leave it to you to fill in the details, but this should be significantly faster than the previous paper approach.
    Follow Math Help Forum on Facebook and Google+

  8. #8
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    I don't see any slick way to do this. My method is essentially the same as undefined's. Namely, for each possible three-digit sum, list how many ways that can occur in the last three digits and in the first three digits, multiply the results together and then add to get the grand total.

    Here is the calculation in tabulated form:

    \begin{array}{r|ccccccccccccccc} \text{sum}&0&1&2&3&\ldots&9&10&11&12&13&14&15&\ldo  ts&26&27\\ \hline \text{\# last 3 digits}&1&3&6&10&\ldots&55&63&69&73&75&75&73&\ldot  s&3&1\\\text{\# first 3 digits}&0&1&3&6&\ldots&45&54&61&66&69&70&69&\ldots  &3&1\\ \hline \text{product}&0&3&18&60&\ldots&2475&3402&4209&481  8&5175&5250&5037&\ldots&9&1<br />
\end{array}

    The columns for sums 3 to 8 are omitted because the digit numbers follow a pattern of triangular numbers. Columns for sums 16 to 25 are omitted because the number of last three digits with sum x is the same as the number with sum 27 – x; and the number of first three digits with sum x is the same as the number with sum 28 – x.

    I make the grand total 50412. So in answer to emakarov's question above, the probability of a "lucky" ticket is 50412/900000, or about 5.6%. When I was a kid, we had four-digit bus tickets. I used to spend the journey trying to factorise the number. For me, a ticket was lucky if it had a prime number.
    Follow Math Help Forum on Facebook and Google+

  9. #9
    MHF Contributor undefined's Avatar
    Joined
    Mar 2010
    From
    Chicago
    Posts
    2,340
    Awards
    1
    I think it's a nice programming exercise to solve for, say, 30 digit numbers.

    Edit: Also, to find the sum of the lucky numbers, and to allow the number of digits to be odd.
    Last edited by undefined; September 15th 2010 at 11:39 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Three-digit numbers
    Posted in the Number Theory Forum
    Replies: 0
    Last Post: June 6th 2011, 11:50 PM
  2. three digit numbers
    Posted in the Math Challenge Problems Forum
    Replies: 14
    Last Post: November 19th 2010, 01:06 PM
  3. Four-Digit Odd Numbers
    Posted in the Statistics Forum
    Replies: 2
    Last Post: September 10th 2009, 01:50 PM
  4. Numbers less than a million containing the digit 2.
    Posted in the Discrete Math Forum
    Replies: 6
    Last Post: April 27th 2009, 01:31 PM
  5. [SOLVED] multiplying three and four-digit numbers..
    Posted in the Algebra Forum
    Replies: 0
    Last Post: February 4th 2008, 05:03 PM

Search Tags


/mathhelpforum @mathhelpforum