Calculate Factorial

Calculate the factorial of a number:

Factorial Formula:
n! = n × (n-1) × (n-2) × … × 1
0! = 1 (by definition)
Example: 5! = 5 × 4 × 3 × 2 × 1 = 120
Example: 3! = 3 × 2 × 1 = 6

Understanding Factorials

Factorials are fundamental mathematical operations that appear in combinatorics, probability theory, statistics, and many areas of computer science. They represent the number of ways to arrange or select items.

What is a Factorial?

📊 Definition

n! = n × (n-1) × (n-2) × … × 1
Product of all positive integers ≤ n
0! = 1 (by convention)
Not defined for negative integers
Grows extremely rapidly

🔢 Examples

1! = 1
2! = 2 × 1 = 2
3! = 3 × 2 × 1 = 6
4! = 4 × 3 × 2 × 1 = 24
5! = 5 × 4 × 3 × 2 × 1 = 120
10! = 3,628,800

⚡ Growth Rate

Factorials grow faster than exponentials
10! = 3.6 million
20! ≈ 2.4 × 10^18
50! ≈ 3.0 × 10^64
100! ≈ 9.3 × 10^157
Extremely large numbers

Factorial Examples

n n! Calculation Application
0 1 0! = 1 Empty set
1 1 1! = 1 Single item
2 2 2! = 2 × 1 = 2 Two arrangements
3 6 3! = 3 × 2 × 1 = 6 Permutations of 3 items
4 24 4! = 4 × 3 × 2 × 1 = 24 Playing card arrangements
5 120 5! = 5 × 4 × 3 × 2 × 1 = 120 Lottery combinations
6 720 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720 Dice probability

Practical Applications

🎯 Combinatorics

Permutations: P(n,k) = n! / (n-k)!
Combinations: C(n,k) = n! / (k! × (n-k)!)
Arranging and selecting items
Counting techniques
Discrete mathematics

📊 Probability & Statistics

Probability calculations
Statistical distributions
Random sampling
Hypothesis testing
Quality control
Risk assessment

🎮 Games & Gambling

Lottery probability
Card game odds
Dice combinations
Sports betting
Casino mathematics
Game theory

💻 Computer Science

Algorithm complexity: O(n!)
Brute force algorithms
Permutation generation
Sorting algorithms
Cryptographic methods
Data structures

🧬 Mathematics

Series expansions
Power series
Gamma function
Number theory
Graph theory
Discrete mathematics

🏭 Engineering

Quality control sampling
System reliability
Network configurations
Manufacturing processes
Process optimization
Risk analysis

Factorial Properties

🔗 Recurrence Relation

n! = n × (n-1)!
Recursive definition
Multiplicative property
Builds from smaller factorials
Example: 5! = 5 × 4! = 5 × 24 = 120

📈 Growth Properties

Rapidly increasing function
Super-exponential growth
Stirling's approximation
Growth rate analysis
Asymptotic behavior
Large number properties

🔢 Number Properties

Highly composite numbers
Many prime factors
Divisible by all smaller integers
Number theory applications
Integer properties
Factorization patterns

⚖️ Comparison Properties

n! grows faster than c^n
Exponential vs factorial growth
Asymptotic comparisons
Growth rate hierarchies
Computational complexity
Algorithm analysis

💡 Factorial Tip: Factorials grow extremely rapidly - 10! = 3,628,800 and 20! is already over 2 quintillion! They're essential for calculating permutations, combinations, and probabilities in games, statistics, and computer science.

Advanced Factorial Concepts

🔬 Gamma Function

Γ(n+1) = n! for integer n
Extension to real numbers
Complex analysis
Special functions
Advanced calculus
Mathematical physics

📈 Stirling's Formula

n! ≈ √(2πn) × (n/e)^n
Approximation for large n
Asymptotic analysis
Computational methods
Number theory
Statistical applications

🔐 Double Factorial

n!! = n × (n-2) × (n-4) × …
Every other number
Special values
Mathematical constants
Advanced calculations
Number sequences

🎲 Probability Distributions

Poisson distribution
Binomial coefficients
Hypergeometric distribution
Statistical sampling
Quality control
Risk analysis

Historical Development

🏛️ Ancient Origins

Indian mathematics (9th century)
Persian mathematicians
Combinatorial problems
Ancient counting methods
Early probability concepts
Game analysis

📚 Renaissance Mathematics

European mathematicians
Permutation theory
Probability foundations
Card game analysis
Statistical methods
Mathematical notation

⚙️ Modern Applications

Computer algorithms
Statistical software
Scientific computing
Financial modeling
Cryptographic systems
Machine learning

Factorial in Real Life

🎰 Lotteries & Gambling

Calculate lottery odds
Understand probability
Make informed decisions
Expected value calculations
Risk assessment
Game strategy

📊 Business & Quality Control

Sampling plans
Quality assurance
Process control
Risk management
Statistical analysis
Decision making

🔬 Scientific Research

Statistical analysis
Experimental design
Data interpretation
Research methodology
Scientific computing
Mathematical modeling

💻 Software Development

Algorithm complexity
Performance analysis
Optimization techniques
Data structure design
Problem solving
Computational thinking