Pseudo code+factorial
' 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
#!/usr/bin/perl print factorial($ARGV[11]); sub factorial { my($num) = @_; if($num == 1) { return 1; # stop at 1, factorial doesn't multiply times zero } else { return $num * factorial($num - 1); # call factorial function recursively } }
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;
18! = 6,402,373,705,728,000
18 factorial is equal to 6402373705728000 - with three consecutive zeroes at the end.
There are 18 zeros.
20! = 2.432902008176 E+18
20! = 2.432902008176 E+18
The value of 9 factorial plus 6 factorial is 363,600
It is 4060.
factorial of -1
26 factorial is 403,291,461,126,605,635,584,000,000
Zero factorial = 1
34 factorial = 295,232,799,039,604,140,847,618,609,643,520,000,000.
1 factorial = 1