The following is not tested:
function factorial
parameters number
private product, i
product = 1
for i = 1 to number
product = product * i
next
return product
The following is not tested:
function factorial
parameters number
private product, i
product = 1
for i = 1 to number
product = product * i
next
return product
The following is not tested:
function factorial
parameters number
private product, i
product = 1
for i = 1 to number
product = product * i
next
return product
The following is not tested:
function factorial
parameters number
private product, i
product = 1
for i = 1 to number
product = product * i
next
return product
Pseudo code+factorial
<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>
bwiset
#include<stdio.h> #include<conio.h> main() { int f=1,i=1,n; clrscr(); printf("\n Enter factorial value"); scanf("%d",&n); for(;i<=n;i++) { f=f*i; } printf("\n The factorial value=%d",f); getch(); }
If you really wanted to do this, you could simulate multiplication with repeated addition.
i need a pic of cuson
Factorials are the product of 1 and all the integers up to the given number. Simply put, 5 factorial or 5! = 5*4*3*2*1
FoxPro doesn't have any special factorial function, so you would have to write your own factorial function. It's fairly easy, for example:function factoriallparameters nresult = 1for i = 1 to nresult = result * nnextreturn resultIf you have an older version of FoxPro, you may need to replace "lparameters" by "parameters".Or even simpler, with recursion:function factoriallparameters nreturn iif(n
Kat
Pseudo code+factorial
#define fact(n) ( n == 0 ? 1 ; (n*(fact(n-1) ) ) )
/*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); }
<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>
If you have N things and want to find the number of combinations of R things at a time then the formula is [(Factorial N)] / [(Factorial R) x (Factorial {N-R})]
Take the total number of letters factorial, then divide by the multiple letters factorial (a and e). 7! / (2!*2!) or 1260.
chutia mc,bc bhosdika
Actually, a for loop is more appropriate in this case. With while, it would be something like the following pseudocode - adapt to your favorite programming language:function factorial(n)result = 1factor = 1while factor