{"id":18184,"date":"2021-09-30T11:00:17","date_gmt":"2021-09-30T05:30:17","guid":{"rendered":"https:\/\/python-programs.com\/?p=18184"},"modified":"2021-11-22T18:35:32","modified_gmt":"2021-11-22T13:05:32","slug":"python-program-for-double-factorial","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-double-factorial\/","title":{"rendered":"Python Program for Double Factorial"},"content":{"rendered":"

In the previous article, we have discussed Python Program for Product of Maximum in First array and Minimum in Second<\/a>
\nFactorial:<\/strong><\/p>\n

The product of all positive integers less than or equal to n is the factorial of a non-negative integer n, denoted by n! in mathematics:<\/p>\n

n! = n * (n – 1) *(n – 2) * . . . . . . . . . . 3 * 2 * 1.<\/strong><\/p>\n

4 != 4 * 3 * 2 *1=24<\/p>\n

Double Factorial:<\/strong><\/p>\n

The product of all the integers from 1 to n with the same parity (odd or even) as n is the double factorial of a non-negative integer n. It is also known as a number’s semi factorial and is denoted by!!.<\/p>\n

For example, the double factorial of 7 is 7*5*3*1 = 105<\/strong><\/p>\n

It is worth noting that as a result of this definition, 0!! = 1.<\/p>\n

The double factorial for even number ‘n’ is:<\/p>\n

\"n!!=prod_{k=1}^{n\/2}(2k)=n(n-2)(n-4).....4*2\"<\/p>\n

The double factorial for odd number ‘n’ is:<\/p>\n

\"n!!=prod_{k=1}^{{n+1}\/2}(2k-1)=n(n-2)(n-4).....3*1\"<\/p>\n

Given a number ‘n’ and the task is to find the double factorial of a given number.<\/p>\n

Examples:<\/strong><\/p>\n

Example 1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given number = 5<\/pre>\n

Output:<\/strong><\/p>\n

The double factorial of a given number{ 5 } =  15<\/pre>\n

Example 2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given number = 10<\/pre>\n

Output:<\/strong><\/p>\n

The double factorial of a given number{ 10 } =  3840<\/pre>\n

Program for Double Factorial in Python<\/h2>\n

Below are the ways to find the double factorial of a given number.<\/p>\n