#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(); }
To get the factorial of a number, "n", do one of the following:
1) Multiply all numbers from one to "n". To do this, assign the number 1 to the result, then write a loop (from 1 to n) that will multiply result by each of the numbers the loop counter assumes.
2) Another method is to use recursion. If n = 0, return 1; otherwise, the factorial of n is equal to n * factorial(n - 1).
Just try every factorial numbers (1, 2, 6, 24, 120 and so far) whether or not they divide the given number.
That's not the factorial of any number. For a start, the factorial of any number greater than or equal to 2 is even, because of the factor 2. The factorial of any number greater or equal to five ends with 0. Another answer: I suspect the questioner meant to ask how to write 8*7*6*5*4*3*2*1 as a factorial. If so, then the answer is "8!"
#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;
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
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>
The greatest factor of any number is the number itself.
The greatest factor of any number is the number itself. The second greatest factor of any even number is half the number. The second greatest factor of any composite number is the number divided by its smallest prime factor. The second greatest factor of any prime number is 1.
The greatest factor of a number is the number itself. So, the greatest factor of 60 is 60.
The greatest factor of any positive number is the number itself.
The greatest factor of any number is the number itself.
The greatest factor of any number is the number itself.
The greatest factor of any number is the number itself.
Every number is the greatest factor of itself.
The greatest factor of any number is the number itself.
The greatest factor of any number is the number itself.
The greatest factor of any positive number is the number itself.
The greatest factor of any number is the number itself.