#C12751. Sum of Primes
Sum of Primes
Sum of Primes
Given an integer n, your task is to compute the sum of all prime numbers less than or equal to n. A prime number is defined as a positive integer greater than 1 that has no positive divisors other than 1 and itself. If the input is not a positive integer (for example, if it is negative or not an integer at all), then the output should be 0.
Your solution must read the input from the standard input (stdin) and print the output to the standard output (stdout). The use of external libraries or built-in functions that directly solve the problem is not allowed. Efficiency is encouraged, because some inputs can be large.
Note: The mathematical definition of a prime can be expressed as: \[ p \text{ is prime } \iff p > 1 \; \text{and}\; \forall d \in \mathbb{N}, \; \text{if } 1 < d < p, \; d \nmid p \]
inputFormat
Input consists of a single line containing a single token, which should represent an integer n. If the token cannot be interpreted as an integer, the program must output 0.
outputFormat
Output a single integer which is the sum of all prime numbers less than or equal to n. In the case of invalid input, output 0.
## sample10
17