#C1924. Factorial Number Selector
Factorial Number Selector
Factorial Number Selector
You are given a list of integers. An integer is called a factorial number if it can be expressed as k! for some positive integer k. In mathematical terms, a number n is a factorial number if there exists an integer k ≥ 1 such that:
\( n = k! = 1 \times 2 \times \cdots \times k \)
Your task is to filter out all the factorial numbers from the given list and print them in ascending order, each on a new line. If there are no factorial numbers in the list, print nothing.
Note: The number 1 is considered a factorial number since \(1 = 1!\).
inputFormat
The input is given in two lines:
- The first line contains an integer n (the number of items in the list).
- The second line contains n space-separated integers.
outputFormat
Output the factorial numbers from the list in ascending order. Each number should be printed in a separate line. If no factorial numbers are found, output nothing.
## sample6
1 2 6 24 120 720
1
2
6
24
120
720
</p>