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!
no answer....pls post
kjhk
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
#include <iostream> using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number<1 number>10) { cout << "Enter integer number (1-10) = "; cin >> number; } // Calculate the factorial with a FOR loop for(i=1; i<=number; i++) { factorial = factorial*i; } // Output result cout << "Factorial = " << factorial << endl;
<html> <script language="vbscript"> n=cint(inputbox("Enter a number")) dim f f=1 if n<0 then Msgbox "Invalid number" elseif n=0 or n=1 then MsgBox "The factorial of given number "&n&" is :"&f else for i=n to 2 step -1 f=f*i next MsgBox "The factorial of given number "&n&" is :"&f end if </script> </html>
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)
chutia mc,bc bhosdika
(4 times 4 factorial + 4) divided by 4 4 factorial + the square root of 4 minus (4 divided by 4)
//C program to find the factorial of a given number using functions #include<stdio.h> #include<conio.h> int fact(int); void main() { int f,t; clrscr(); printf("\nEnter any number:"); scanf("%d",&f); t=fact(f); printf("1=%d",t); getch(); } int fact(int fa) { int i,fac=1,t; for(i=fa;i>=2;i--) { // TO print the series printf("%dx",i); fac=i*fac; } return fac; }
/*program to find the factorial of a given number*/ #include<stdio.h> #include<conio.h> int fact(int); void main() { int n,c; printf("\n enter the number for which you want to find the factorial"); scanf("%d",&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); }
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.
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 > 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).