factorial

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kpdhiman
    New Member
    • Jul 2007
    • 1

    factorial

    Pl. Help me in solving factorial of any number in c languguage
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by kpdhiman
    Pl. Help me in solving factorial of any number in c languguage
    Have you tried anything? If yes, kindly paste code snippet here so I can help you.

    Regards

    Comment

    • sicarie
      Recognized Expert Specialist
      • Nov 2006
      • 4677

      #3
      Do you have an algorithm to accomplish this yet? I would start there.

      Comment

      • emaghero
        New Member
        • Oct 2006
        • 85

        #4
        Originally posted by kpdhiman
        Pl. Help me in solving factorial of any number in c languguage
        Given an positive integer n, the factorial of that number is the product of that number with all the numbers that preceed it. It is denoted by n!, pronounced n factorial.

        n! = n*(n-1)*(n-2)*.....3*2*1

        0!=1
        1!=1

        by convention.

        To write a function which computes n! you could use recursion or a control structure, for/ while loop.

        The structure of a function that computes the factorial might go as follows

        Step 1: Error condition that eliminates the calculation of factorials of negative integers.
        Step 2: Define the base cases 0!=1, 1!=1
        Step 3: Implement the factorial algorithm as defined above.

        Hope this has been of some help.

        Comment

        Working...