Results 1 to 3 of 3

Math Help - Hello M.h.f - New member in need of some help.

  1. #1
    Newbie
    Joined
    Dec 2009
    Posts
    9

    Hello M.h.f - New member in need of some help.

    Hello everyone,

    As the title says this is my first post, as my ability in math grows I hope to give help and not just ask for it! Anyway...

    Long story short I have recently began self study into computer programming and enjoying it very much. It quickly came to my attention that math (discrete math) is at work here. My travels through the net also lead me to believe that some take the "well you can still do alot without math!" approach (not pointing fingers).

    However I want to learn and understand the math and am prepared to work at it. To that extent I've purchased a book (bet you didn't see that coming) explaining the math to help me get started. I'm rather annoyed (with myself?) however to say that not far in and the problems have begun...but not wanting to give up I have come to get some help.

    The question is below and is algebraic in nature I believe;
    This is in pseudo code by the way but hopefully wont hinder much;

    if; a) n = 3
    b) n = 5

    begin
    f := 1;
    input n;
    for i := 1 to n do
    f := f * i
    Output f;
    end

    The book gives answers of f = 6 and f = 120 respectively.

    If someone could explain just how these answers are being reached as I feel as though I understand then upon checking with the answers that conception goes up in smoke.

    Thank-you in advance for any help,
    - Jamie.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A riddle wrapped in an enigma
    masters's Avatar
    Joined
    Jan 2008
    From
    Big Stone Gap, Virginia
    Posts
    2,551
    Thanks
    11
    Awards
    1
    Quote Originally Posted by Skeith View Post
    Hello everyone,

    As the title says this is my first post, as my ability in math grows I hope to give help and not just ask for it! Anyway...

    Long story short I have recently began self study into computer programming and enjoying it very much. It quickly came to my attention that math (discrete math) is at work here. My travels through the net also lead me to believe that some take the "well you can still do alot without math!" approach (not pointing fingers).

    However I want to learn and understand the math and am prepared to work at it. To that extent I've purchased a book (bet you didn't see that coming) explaining the math to help me get started. I'm rather annoyed (with myself?) however to say that not far in and the problems have begun...but not wanting to give up I have come to get some help.

    The question is below and is algebraic in nature I believe;
    This is in pseudo code by the way but hopefully wont hinder much;

    if; a) n = 3
    b) n = 5

    begin
    f := 1;
    input n;
    for i := 1 to n do
    f := f * i
    Output f;
    end

    The book gives answers of f = 6 and f = 120 respectively.

    If someone could explain just how these answers are being reached as I feel as though I understand then upon checking with the answers that conception goes up in smoke.


    Thank-you in advance for any help,
    - Jamie.
    Hi Skeith,

    The value of f is initially set at 1.

    The input command allows for n = 3

    The loop command 'for i = 1 to n do f:= f*i' does the following:

    First pass: f = 1, i = 1, f*i = 1
    Second pass: f = 1, i = 2, f*i = 2
    Third pass: f = 2, i = 3, f*i = 6

    f is replaced each pass with the the value of the new product. The final product is 6. Thus, output 6.

    The same thing happens for an input of 5, except the loop has 5 passes

    First pass: f = 1, i = 1, f*i = 1
    Second pass: f = 1, i = 2, f*i = 2
    Third pass: f = 2, i = 3, f*i = 6
    Fourth pass: f = 6, i = 4, f*i = 24
    Fifth pass: f = 24, i = 5, f*i = 120
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2009
    Posts
    9
    Thankyou for the reply masters! I feel I have a better grip of it already, I believe I also see the flaw in my approach. I was not allowing for the value of f to be updated thus it was staying at one (silly I know). I'll write that post out and slip it in my book to re-read - just wanted to thank you for the response!
    Last edited by Skeith; December 1st 2009 at 11:49 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. new member need to help
    Posted in the Statistics Forum
    Replies: 2
    Last Post: November 30th 2009, 10:57 AM

Search Tags


/mathhelpforum @mathhelpforum