Results 1 to 3 of 3

Thread: More math help!     submit to reddit submit to twitter

  1. #1
    Nidhogg
    Join Date
    Oct 2006
    Posts
    3,665
    BG Level
    7

    More math help!

    I'm trying to find the number of ways to pay 8$ into a vending machine where the machine only accepts 1$, 2$ and 5$

    I need to do this with recursion

    I understand that you denote an = # of ways to pay N dollars

    and you do the recursion by finding the number of ways to pay 8$ with respect to the first coin you drop

    The thing I'm confused about is how to iterate the initial conditions.

    If this example is too hard, perhaps try to answer this question..

    How many strings of N-digits contain an even number of zeroes

    again, I understand how to setup the recursion to solve for an, but not the initial conditions.

  2. #2
    Bagel
    Join Date
    Nov 2005
    Posts
    1,460
    BG Level
    6
    FFXI Server
    Ragnarok

    Re: More math help!

    Does order matter?
    Like is 5-2-1 different from 2-5-1?

  3. #3
    Nidhogg
    Join Date
    Oct 2006
    Posts
    3,665
    BG Level
    7

    Re: More math help!

    Let me try to explain the first few steps to let you know what I mean by iterating the initial conditions.

    First, I let an = number of ways to pay n dollars

    now we solve by cases.

    1) if the first coin dropped is 1$, then you have (an-1) ways of paying 8 dollars
    2) if the first coin dropped is 2$, then you have (an-2) way sof pyaing 8 dollars
    3) if the first coin dropped is 5$, then you have (an-5) ways of paying 8 dollars.

    so now you can come up with a recursion formula as follows:

    an = (an-1) + (an-2) ------------- for n<5

    and

    an = (an-1) + (an-2) + (an-5) ---- n>5

    note: the n-x is a subscript

    obviosly you need to solve for a8

    but you need initial conditions to start the iteration from a2
    to solve for a2, you need a1 and a0 to start off your iteration. using the 1st equation.

    my notes say:

    a0 = 1 -> pay nothing
    a1 = 1 -> {1,1} {2,0}

    I get how to do the rest, but not the initial conditions.

Similar Threads

  1. Really quick, simple math help needed >_>
    By ertyu in forum General Discussion
    Replies: 7
    Last Post: 2009-04-14, 01:45
  2. Math help (woozie help please!)
    By Saga in forum General Discussion
    Replies: 2
    Last Post: 2008-12-05, 01:28
  3. math help!
    By Ksandra in forum General Discussion
    Replies: 8
    Last Post: 2008-06-11, 22:15
  4. Other Random Math Help Prz
    By Keno in forum General Discussion
    Replies: 1
    Last Post: 2007-12-03, 11:24
  5. Math helps please!
    By gt_killa in forum General Discussion
    Replies: 20
    Last Post: 2007-08-30, 00:00
  6. Math help bad!
    By Ikith in forum General Discussion
    Replies: 40
    Last Post: 2007-02-22, 21:57
  7. need math help again :D
    By untouchable in forum General Discussion
    Replies: 11
    Last Post: 2006-02-28, 21:34
  8. need math help part2
    By untouchable in forum General Discussion
    Replies: 12
    Last Post: 2006-02-01, 13:58