Follow

Translate

Tuesday, March 15, 2016

FACTORIAL(FACT, N)

This procedure calculate N! and returns the value in the variable FACT.

1.  If N = 0, then:Set FACT : = 1, and return.

2.  Set FACT : = 1. [Initializes FACT for loo.]

3.  Repeat for K = 1 to N.
        Set FACT : = K*FACT.
[End of loop.]

4.   Return.


Procedure B: FACTORIAL(FACT, N)
This procedure calculate N! and returns the value in the variable FACT.

1.   If N = 0, then:Set FACT : = 1, and return.

2.  Call FACTRIAL(FACT, N-1)

3.    Set FACT : = K*FACT.
4.   Return.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

Related Posts:

  • FACTORIAL(FACT, N) Procedure A: FACTORIAL(FACT, N) This procedure calculate N! and returns the value in the variable FACT. 1.  If N = 0, then:Set FACT : = 1, and return. 2.  Set FACT : = 1. [Initializes FACT for loo.] 3.  Re… Read More
  • PUSH(STACK, TOP, MAXSTK, ITEM) PUSH(STACK, TOP, MAXSTK, ITEM):   This procedure pushes an ITEM onto a stack. 1.   [Stack already filled?]       If TOP = MAXSTK, then: Print:OVERFLOW, and return. 2.  Set … Read More
  • POP(STACK, TOP, ITEM):   This procedure deletes the top element of STACK and assigns it to the variable ITEM 1.   [Stack has an ITEM to be remove?]       If TOP = 0, then: Print:… Read More
  • What is Ackermann Function? Ackermann Function:  The Ackermann function is a function with two arguments each of which can be assigned any nonnegative integer: 0, 1, 2,........... This function is defined as follows: (a)  If m = 0 , then A… Read More
  • FIBONACCI(FIB, N) FIBONACCI(FIB, N) This procedure calculates FN and returns the value in the first parameter FIB. 1.  If N = 0 or N = 1, then : Set FIB : = N, and return. 2. Call FIBONACCI(FIBA, N-2). 3. Call FIBONACCI(FIBB, N-1… Read More

0 comments:

Post a Comment