#include<stdio.h>
#include<conio.h>
int factr(int x);
void main()
{
int a,fact;
printf("\n Enter a value: ");
scanf("%d",&a);
fact=factr(a);
printf("\n Factorial: %d",fact);
getch();
}
int factr(int x)
{
int f,i;
f=1;
for(i=x;i>=1;i--)
f=f*i;
return f;
}
no answer....pls post
' Iterative solution Function iterativeFactorial(ByVal n As Long) As Long Dim factorial As Long = 1 For i As Long = 1 To n factorial *= i Next Return factorial End Function ' Recursive solution Function recursiveFactorial(ByVal n As Long) As Long If n <= 1 Then Return n End If Return n * recursiveFactorial(n - 1) End Function
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!
#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;
A recursive function is one that calls upon itself until a given result in the original call is met. Take a look at this example. Program Recursion; Uses crt; Var number:longint; Function Factorial(number:longint):longint; Begin if number > 0 then factorial:=number*factorial(number-1) else factorial:=1; End; Begin clrscr; readln(number); writeln(factorial(number)); readln; End. Note how the function factorial calls itself.
An exclamation mark after a number is the symbol for the factorial function.
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)
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
kjhk
factorial number Var num= prompt("enter any number "); Var i=1; Var fact=1; for(i=1;i
chutia mc,bc bhosdika
(4 times 4 factorial + 4) divided by 4 4 factorial + the square root of 4 minus (4 divided by 4)