Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Explain Function Factorial()

    Can someone break this down for me so I can understand what a factorial does?

    I'm working with C and what I read doesn't make sense to me.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Jus S View Post
    Can someone break this down for me so I can understand what a factorial does?

    I'm working with C and what I read doesn't make sense to me.
    factorial(n) compute the product of all numbers from 1 to n:

    Code:
    factorial(3) = 1*2*3
    factorial(4) = 1*2*3*4
    factorial(7) = 1*2*3*4*5*6*7
    probably you learn about recursivity and need one of his property:

    Code:
    factorial(n) = n * factorial(n-1);
    best regards

  • Users who have thanked oesxyl for this post:

    Jus S (11-11-2008)

  • #3
    New Coder
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Just in case you were wondering what some applications of the Factorial function are, in maths n! (factorial) returns the number of ways that n number of objects can be arranged. For example there are 7 possibilities that can go in the first place, then 6 that can go in the second spot, and so forth.
    Hope this helped
    happy coding.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •