While6. An integer N (> 0) is given. Find the double factorial N:
\(N!! = N \cdot (N - 2) \cdot (N - 4) \cdot ...\)
(The last factor is 2 if N is even, and 1 if N is odd). To avoid an integer overflow, calculate this product using a real variable and print it as a real number.
Solution in Python 3:
import random
N = random.randrange(1,20)
print('N = ', N)
if N%2 == 0:
L = 2
else:
L = 1
F = 1
while N >= L:
F *= N
N -= 2
print("Double factorial: ", F)