answersLogoWhite

0


Best Answer

Use the following function:

unsigned fact (const unsigned n) {

return n<2 ? 1 : n * fact (n-1);

}

Note that for a 32-bit unsigned integer, the largest factorial this function can accommodate is 12!

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find factorial of a given number using function in C.?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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

no answer....pls post


Program for finding the factorial of the two given number using constructor?

kjhk


Programming to calculate a factorial number?

double factorial(double N){double total = 1;while (N > 1){total *= N;N--;}return total; // We are returning the value in variable title total//return factorial;}int main(){double myNumber = 0;cout > myNumber;cout


Write a recursive procedure to compute the factorial of a number?

#include &lt;iostream&gt; using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number&lt;1 number&gt;10) { cout &lt;&lt; "Enter integer number (1-10) = "; cin &gt;&gt; number; } // Calculate the factorial with a FOR loop for(i=1; i&lt;=number; i++) { factorial = factorial*i; } // Output result cout &lt;&lt; "Factorial = " &lt;&lt; factorial &lt;&lt; endl;


How do find factorial using vbscript?

&lt;html&gt; &lt;script language="vbscript"&gt; n=cint(inputbox("Enter a number")) dim f f=1 if n&lt;0 then Msgbox "Invalid number" elseif n=0 or n=1 then MsgBox "The factorial of given number "&amp;n&amp;" is :"&amp;f else for i=n to 2 step -1 f=f*i next MsgBox "The factorial of given number "&amp;n&amp;" is :"&amp;f end if &lt;/script&gt; &lt;/html&gt;


How do you find factors of a number in Excel spreadsheet?

Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)Use the FACT function. So to get the factorial of 5, you would enter:=FACT(5)


By using call by reference find the factorial of a number?

chutia mc,bc bhosdika


How can you get the number 25 by using only number 4?

(4 times 4 factorial + 4) divided by 4 4 factorial + the square root of 4 minus (4 divided by 4)


Write a program to find the factorial number using function?

//C program to find the factorial of a given number using functions #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int fact(int); void main() { int f,t; clrscr(); printf("\nEnter any number:"); scanf("%d",&amp;f); t=fact(f); printf("1=%d",t); getch(); } int fact(int fa) { int i,fac=1,t; for(i=fa;i&gt;=2;i--) { // TO print the series printf("%dx",i); fac=i*fac; } return fac; }


Program to find the factorial of a number using recursion?

/*program to find the factorial of a given number*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int fact(int); void main() { int n,c; printf("\n enter the number for which you want to find the factorial"); scanf("%d",&amp;n); c=fact(n); printf("\n the factorial of the number %d is %d",n,fact); getch(); } int fact(int n) { int k; if(n==0) return(1); else k=n*fact(n-1); return(k); }


What is the algorithm n flowchart for calculating factorial of number using recursion?

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.


What is recursion in programing?

A recursive method (or function) is one that calls itself. Here is a popular example: The factorial function n! (read the exclamation mark as: factorial of n, or n factorial), for a positive integer, is the product of all numbers up to that number. For example, 4! = 1 x 2 x 3 x 4. In math, the factorial is sometimes defined as: 0! = 1 n! = n x (n-1)! (for n &gt; 0) You can write a function or method, using this definition. Here is the pseudocode: function factorial(n) if (n = 0) return 1 else return n * factorial(n - 1) Note that this is not very efficient, but there are many problems that are extremely complicated without recursion, but which can be solved elegantly with recursion (for example, doing something with all files in a folder, including all subfolders).