Factorial Missing Incrementation

Objective

To implement a program that finds the factorial of a given number (with missing incrementation statement). 

 

Theory

The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. Mathematically, it is expressed as: 

                               n!=n×(n−1)×(n−2)×…×3×2×1 

For example 5! Is 5 ×4 ×3×2×1 = 120 and 6!= 6 × 5 × 4 × 3 × 2 × 1 =720 

By convention, 0 is defined to be 1. Factorials are commonly used in mathematics and computer science. Some use cases include combinations and permutations, probability calculations, and solving problems in combinatorics. 

The factorial of a given number is calculated by multiplying all numbers starting from one up to the given number. In programming languages, the next number to be multiplied can be determined using increment operators. Factorials are used to count the number of ways in which a set of distinct elements can be arranged or permuted. For example, if you have n distinct items and you want to find the number of ways to arrange them in a sequence, you will use the factorial, as it gives you the total number of permutations. 

 

Learning Outcomes

  • Understand what a factorial is and how it is calculated.
  • Identify when an incrementation is missing from a factorial.
  • Write code to calculate a factorial with missing incrementation.
  • Debug code to identify and fix errors related to missing incrementation in factorials.
  • Analyze the time complexity of a factorial with missing incrementation.