#C14410. Prime Factorials
Prime Factorials
Prime Factorials
Given a list of integers, your task is to identify all the prime numbers in the list, compute the factorial for each prime, and output a dictionary where each key is a prime number and its corresponding value is the factorial of that number.
Formally, for a given list \(a_1, a_2, \dots, a_n\), if \(p\) is a prime present in the list then compute \(p!\) and include the pair \(p: p!\) in the output dictionary.
Note: Numbers less than or equal to 1 are not considered prime.
inputFormat
The first line contains a single integer \(N\) denoting the number of elements in the list. The second line contains \(N\) space-separated integers.
outputFormat
Output a dictionary (enclosed in curly braces) following the Python dictionary literal format. The dictionary should map each prime number (in increasing order) to its factorial. For example, if the dictionary contains a mapping for the prime number 2 to its factorial 2, it should be printed as {2: 2, ...}
.
9
2 3 4 5 6 7 8 9 10
{2: 2, 3: 6, 5: 120, 7: 5040}