answersLogoWhite

0

A flowchart for factorial of number can be made using different software's. Microsoft Word is the most popular software for beginners to make simple flowcharts.
In order to draw the flowchart write the number at the top of the paper and then draw two lines under it going slightly to the sides. Decide what two numbers can be multiplied to equal that number. Keep going until you can no longer get to smaller numbers.

User Avatar

Wiki User

7y ago

What else can I help you with?

Continue Learning about Engineering

Can you provide a solution to the diamond-square algorithm using Java and recursion?

Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.


Algorithm to find factorial using functions?

factorial using recursion style in c++ is unsigned int fact(unsigned int a) { if (a<=1) return 1; else { f*=fact(a-1); return a; } } when using looping structure factorial is unsigned int fact (unsigned int n) { unsigned int i,f=1; for(i=1;i<=n;i++) f*=i ; return f; }


2 Write a program in java to find factorial of a number?

import java.math.BigInteger; public class Factorial { public static void main(String[] args) { BigInteger n = BigInteger.ONE; for (int i=1; i<=20; i++) { n = n.multiply(BigInteger.valueOf(i)); System.out.println(i + "! = " + n); }


What is the merits and demerit of recursion in algorithm?

The advantages of recursion tend to revolve around the fact that there are quite a few algorithms which lend themselves to recursion (tree traversal, binary searches, quick sort, etc.) The disadvantages of recursion include: * finite number of recursive steps (limited heap space) * speed/efficiency (easier to increment a loop counter than call a function)


How do you overcome limitations of stacks in polygon filling?

You overcome limitations of the stack in polygon filling, or in any other algorithm, far that matter, but using an iterative technique, rather than a recursive technique. Recursion is quite useful, and can simplify algorithm design. Polygon filling, however, is a class of algorithm can potentially have a very deep recursion depth. This causes stress on the stack, hence the need for iteration.

Related Questions

What is the most efficient way to implement a factorial algorithm in a programming language?

The most efficient way to implement a factorial algorithm in a programming language is to use an iterative approach rather than a recursive one. This involves using a loop to multiply the numbers from 1 to the given input number to calculate the factorial. This method is more memory-efficient and faster than using recursion.


Program for calculating factorial no using recursion in c?

factorial n is given by formula n! = n.(n-1)....1 int i; long x; x =1; for (i=n;i>1;i--) x = x*i ; will calculate factorial. I have put x as long to avoid integer overflow. checks for n is positive etc. to be added.


Can you provide a solution to the diamond-square algorithm using Java and recursion?

Yes. It is possible to provide a solution to the diamond-square algorithm using Java and recursion.


Algorithm to find factorial using functions?

factorial using recursion style in c++ is unsigned int fact(unsigned int a) { if (a<=1) return 1; else { f*=fact(a-1); return a; } } when using looping structure factorial is unsigned int fact (unsigned int n) { unsigned int i,f=1; for(i=1;i<=n;i++) f*=i ; return f; }


What is a Flow chart for finding factorial of a given number using recursion function?

no answer....pls post


Which is faster to find factorial whether recursive or dowhile?

recursion is always slower than iteration


2 Write a program in java to find factorial of a number?

import java.math.BigInteger; public class Factorial { public static void main(String[] args) { BigInteger n = BigInteger.ONE; for (int i=1; i<=20; i++) { n = n.multiply(BigInteger.valueOf(i)); System.out.println(i + "! = " + n); }


What are the problems involved in using the recursive functions?

There are no problems when they are used correctly. The main problem is that inexperienced programmer's often assume that a recursive algorithm requires a recursive function when it is not the case at all; most recursive algorithms can be implemented as an iterative loop. However, even when recursion is required, often it is implemented incorrectly. Consider the recursive algorithm to find the factorial of an unsigned value: const unsigned factorial (const unsigned n) { return n<2?1:n*factorial (n-1); } The problem with this is that we are calculating a constant expression at runtime. E.g., the factorial of 5 is always going to be 120. Therefore it makes more sense to calculate the factorial at compile time rather than at runtime. constexpr unsigned factorial (const unsigned n) { return n<2?1:n*factorial (n-1); } So, when we write the following: constexpr unsigned x = factorial (5); The compiler will automatically generate the following equivalent code for us: constexpr unsigned x = 120; In other words, the recursive function is completely optimised away. That's fine when we're dealing with constant expressions, but when we deal with variables we have a problem because there are no variables at compile time: unsigned y = rand (); /* a random value */ unsigned x = factorial (y); Now we cannot take advantage of compile time recursion, we must sacrifice runtime performance in order to calculate the factorial of y, whatever y happens to be at runtime. Thus if y were 5, we incur the following series of function calls: factorial (5) factorial (4) factorial (3) factorial (2) factorial (1) That's 5 function calls in total. Once we reach the exit condition (n<2), the functions unwind to calculate the result: factorial (1) = 1 factorial (2) = 2*factorial(1) = 2*1 = 2 factorial (3) = 3*factorial(2) = 3*2 = 6 factorial (4) = 4*factorial(3) = 4*6 = 24 factorial (5) = 5*factorial(4) = 5*24 = 120 That's a lot of work that has to be done at runtime. Now let's look at the iterative solution: unsigned factorial (unsigned n) { unsigned result=1; while (1<n) result*=n--; return result; } Now we only incur one function call at runtime. We can still use the constant expression version for compile time recursion, but for variables we gain better performance at runtime. Moreover, given the simplicity of the function, the compiler can still optimise away the function call entirely through inline expansion. Thus: unsigned y = rand (); /* a random value */ const unsigned x = factorial (y); Becomes the equivalent of: unsigned y = rand (); /* a random value */ unsigned t1 = y; unsigned t2 = 1; while (1<t1) t2*=t1--; const unsigned x = t2; We still have to perform the calculation, of course, but we no longer incur the penalty of making any unnecessary function calls. At worst, there will be just one function call and only when expanding the function is not possible (which is unlikely in this case). So the only time we really need recursion at runtime is when the benefit of inline expansion becomes counter-productive, resulting in runtime code that is overly-complicated. Typical examples are divide-and-conquer algorithms such as the quicksort algorithm where two recursions are necessary. However, when the final call to a function is a recursion, then we can take advantage of tail-call recursion to eliminate the second recursion; we simply modify the variables and re-invoke the current instance of the function rather than invoking a new instance. However, we can only do this when the local variables would not be required when we return from a recursion.


Can you provide a running example to illustrate the concept of recursion?

Recursion is a programming technique where a function calls itself to solve a problem. An example of recursion is the factorial function, which calculates the product of all positive integers up to a given number. For instance, the factorial of 5 (written as 5!) is calculated as 5 x 4 x 3 x 2 x 1 120. In this calculation, the factorial function calls itself with a smaller number until it reaches the base case of 1.


Can you provide some running examples to illustrate the concept of recursion in programming?

Recursion in programming is when a function calls itself to solve a problem. For example, a common recursive function is calculating the factorial of a number. Here's an example in Python: python def factorial(n): if n 0: return 1 else: return n factorial(n-1) print(factorial(5)) Output: 120 Another example is the Fibonacci sequence, where each number is the sum of the two preceding ones. Here's a recursive function to calculate the nth Fibonacci number: python def fibonacci(n): if n 1: return n else: return fibonacci(n-1) fibonacci(n-2) print(fibonacci(6)) Output: 8 These examples demonstrate how recursion can be used to solve problems by breaking them down into smaller, simpler subproblems.


A program for simple factorial in prolog?

In Prolog, a simple factorial program can be defined using recursion. Here's a basic implementation: factorial(0, 1). % Base case: factorial of 0 is 1 factorial(N, Result) :- N > 0, N1 is N - 1, factorial(N1, Result1), Result is N * Result1. % Recursive case You can query the factorial of a number by calling factorial(N, Result). where N is the number you want to compute the factorial for.


What is the merits and demerit of recursion in algorithm?

The advantages of recursion tend to revolve around the fact that there are quite a few algorithms which lend themselves to recursion (tree traversal, binary searches, quick sort, etc.) The disadvantages of recursion include: * finite number of recursive steps (limited heap space) * speed/efficiency (easier to increment a loop counter than call a function)