-1
\$\begingroup\$

Given a number x, find the sum of all primes up to that number.

The input will always be a positive number, bigger than 2. An upper limit isn't defined, so data types can be ignored. Use whichever you want.

  • This is a , so the shortest code in bytes wins.

Example for 5:

2 + 3 + 5 = 10

Test cases:

Input Output
2 2
3 5
17 58

The input doesn't have to be parsed, so assume you get the "correct" data-type. (int in Java, for example)

\$\endgroup\$
1

1 Answer 1

0
\$\begingroup\$

Thunno 2 S, 2 bytes

æP

Try it online!

Explanation

    # Implicit input
æ   # Filter [1..input] by:
 P  #  Prime check
    # Sum the list
    # Implicit output
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.