Posts

Showing posts from May, 2019

Factorial Number

Image
FACTORIAL NUMBER The factorial of a positive integer  n , denoted by  n ! , is the product of all positive integers less than or equal to  n . For example, {\displaystyle 5!=5\times 4\times 3\times 2\times 1=120\,.} The value of 0! is 1, according to the convention for an empty product Mathematically, the formula for the factorial is as follows. If  n  is an integer greater than or equal to 1, then n  ! =  n  (  n  - 1)(  n  - 2)(  n  - 3) ... (3)(2)(1) If  p  = 0, then  p  ! = 1 by convention. We can easily calculate a factorial from the previous one: As a table: n n! 1 1 1 1 2 2 ×  1 = 2 ×  1! = 2 3 3 ×  2 × 1 = 3 ×  2! = 6 4 4 ×  3 × 2 × 1 = 4 ×  3! = 24 5 5 ×  4 × 3 × 2 × 1 = 5 ×  4! = 120 6 etc etc C Program for Factorial of a Number #include <stdio.h> int main () { int n , i ; unsigned long long factorial = 1 ; printf ( "Enter an integer: " ); scanf ( "%d" ,& n ); // show