#C11753. Prime Summation and Factorization
Prime Summation and Factorization
Prime Summation and Factorization
Given a positive integer \( n \), your task is to perform two computations:
- Calculate the sum of all prime numbers not greater than \( n \). Formally, compute \( S = \sum_{p \le n} p \), where \( p \) is a prime number.
- Determine the prime factorization of \( n \). Represent the factorization as a list of tuples \((p, e)\), where \( p \) is a prime factor and \( e \) is its exponent. The factors should be listed in increasing order. If \( n = 1 \), output an empty list
[]
.
The answer must be produced by reading from standard input and writing to standard output.
inputFormat
The input consists of a single integer \( n \) provided through standard input.
outputFormat
The output should consist of two lines:
- The first line contains the sum of all primes up to and including \( n \).
- The second line contains the prime factorization of \( n \) in the format of a Python-style list of tuples. For example, for \( n = 10 \), the output should be:
[(2, 1), (5, 1)]
. If \( n = 1 \), output[]
.
10
17
[(2, 1), (5, 1)]
</p>