#C14778. Prime Number Functions: Filtering, Maximum, and Summation

    ID: 44464 Type: Default 1000ms 256MiB

Prime Number Functions: Filtering, Maximum, and Summation

Prime Number Functions: Filtering, Maximum, and Summation

You are given a list of integers. Your task is to write a program that performs the following operations:

  • Filter out all numbers that are prime.
  • Find the highest prime number in the list. If there is no prime number, output None.
  • Calculate the sum of all prime numbers in the list.

The definition of a prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. Formally, a number \( n \) (where \( n > 1 \)) is prime if and only if:

\[ n \text{ is prime if } \forall d \in \mathbb{Z},\; 2 \le d \le \lfloor \sqrt{n} \rfloor, \; d \nmid n \]

You should read the input from standard input (stdin) and write the output to standard output (stdout).

inputFormat

The input consists of a single line containing space-separated integers.

outputFormat

The output should consist of three lines:

  1. The first line prints the filtered prime numbers in the same order as they appear in the input, separated by a space. If there are no prime numbers, print None.
  2. The second line prints the highest prime number. If there is no prime, print None.
  3. The third line prints the sum of all prime numbers. If there are no prime numbers, print 0.
## sample
10 15 3 7 11 2 20 13 5
3 7 11 2 13 5

13 41

</p>