#K83847. Prime Factors Count
Prime Factors Count
Prime Factors Count
Given a positive integer \(n\), your task is to compute its prime factorization and output the result as a dictionary, where each key is a prime factor and its corresponding value is the count (i.e., the exponent) of that factor in the factorization. For example, if \(n = 18\), then its prime factorization is \(18 = 2^1 \times 3^2\), and the expected output is {2: 1, 3: 2}
.
Note: The input is provided via stdin
and the result must be printed to stdout
in exactly the format shown in the examples.
Recall that for any integer \(n\) (with \(n\geq1\)), if \(n = 1\) then there are no prime factors, and the output should be {}
.
inputFormat
The input consists of a single line containing one integer \(n\) (where \(n \geq 1\)).
outputFormat
Output a single line representing the dictionary of prime factors and their counts in the following format: {p1: c1, p2: c2, ...}
where the prime factors are listed in increasing order.
18
{2: 1, 3: 2}