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)


1 Answer 1


Thunno 2 S, 2 bytes


Try it online!


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

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