[Question]
  [
Write the shortest code for finding the sum of primes between \$a\$ and \$b\$ (inclusive).
**Input**
1. \$a\$ and \$b\$ can be taken from command line or stdin (space seperated)
2. Assume \$1 \le a \le b \le 10^8\$
**Output**
Just print the sum with a newline character.
**Bonus Points**
1. If the program accepts multiple ranges (print one sum on each line), you get extra points. :)
  
[Answer]
# J,41 32 19 characters:
*Update*
(simple sieve)
```
g=:+/@(*1&p:)@-.&i.
```
e.g.
```
100 g 1
1060
250000x g 48
2623030823
```
*Previous*
```
h=:3 :'+/p:i.(_1 p:>:y)'
f=:-&h<:
```
eg:
```
100 f 1
1060
```
[Answer]
## Mathematica 7 (31 chars in plain text)
If PARI/GP solution allowed, then:
```
Plus@@Select[Range[a,b],PrimeQ]
```
[Answer]
# C, 117 bytes
```
main(a,b,s,j){
s=0,scanf("%d%d",&a,&b);
for(a+=a==1;a<=b;a++)
for(s+=a,j=2;j<a;)
s-=a%j++?0:(j=a);
printf("%d",s);
}
```
[Answer]
# C#, 294 characters
```
using System;class P{static void Main(){int a=int.Parse(Console.ReadLine()),b=int.Parse(Console.ReadLine());long t=0;for(int i=a;i<=b;i++)if(p(i))t+=i;Console.WriteLine(t);}static bool p(int n){if((n%2<1&&n!=2)||n<2)return 0>1;for(int i=3;i<=Math.Sqrt(n);i+=2)if(n%i==0)return 0>1;return 1>0;}}
```
[Answer]
# Perl, 62 chars
```
<>=~/\d+/;map$s+=$_*(1x$_)!~/^1$|(^11+)\1+$/,$&..$';print$s,$/
```
This one uses the prime number regex.
[Answer]
# C#, 183 characters
```
using System;class P{static void Main(string[] a){long s=0,i=Math.Max(int.Parse(a[0]),2),j;for(;i<=int.Parse(a[1]);s+=i++)for(j=2;j<i;)if(i%j++==0){s-=i;break;}Console.WriteLine(s);}}
```
This would be much shorter if it didn't have to check for 1, or if there was a better way to... In a more readable format:
```
using System;
class P 
{ 
    static void Main(string[] a) 
    { 
        long s = 0,
             i = Math.Max(int.Parse(a[0]),2),
             j;
        for (; i <= int.Parse(a[1]);s+=i++)
            for (j = 2; j < i; )
                if (i % j++ == 0)
                {
                    s -= i;
                    break;
                }
        Console.WriteLine(s); 
    }
}
```
[Answer]
# PARI/GP, 44 characters
```
sum(x=nextprime(a),precprime(b),x*isprime(x))
```
[Answer]
# BASH Shell, 47 Characters
```
seq 1 100|factor|awk 'NF==2{s+=$2}END{print s}'
```
Edit: Just realized the sum overflows and is coerced as a double.
### 52 50 Characters
Here's a bit longer solution, but handles overflows aswell 
```
seq 1 100|factor|awk NF==2{print\$2}|paste -sd+|bc
```
[Answer]
## Haskell (80)
```
c=u[2..];u(p:xs)=p:u[x|x<-xs,x`mod`p>0];s a b=(sum.filter(>=a).takeWhile(<=b))c
```
`s 1 100 == 1060`
[Answer]
## APL (25 characters)
```
+/((R‚â•‚éï)^~R‚àäR‚àò.√óR)/R‚Üê1‚Üì‚ç≥‚éï
```
This is a modification of a well-known idiom (see [this page](http://www.users.cloud9.net/%7Ebradmcc/APL.html) for an explanation) for generating a list of primes in APL.
Example:
```
      +/((R‚â•‚éï)^~R‚àäR‚àò.√óR)/R‚Üê1‚Üì‚ç≥‚éï
‚éï:
      100
‚éï:
      1
1060
```
[Answer]
## Normal Task (Python 3): 95 chars
```
a,b=map(int,input().split())
r=range
print(sum(1%i*all(i%j for j in r(2,i))*i for i in r(a,b+1)))
```
## Bonus Task (Python 3): 119 chars
```
L=iter(map(int,input().split()))
r=range
for a,b in zip(L,L):print(sum(1%i*all(i%j for j in r(2,i))*i for i in r(a,b+1)))
```
[Answer]
# Pari/GP (24 characters)
```
s=0;forprime(i=a,b,s+=i)
```
Like some other solutions, this doesn't strictly meet the requirements, as `a` and `b` aren't read from stdin or the command line. I thought it was a nice alternative to the other Pari/GP and Mathematica solutions however.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 7 bytes
```
√≤V fj x
```
[Try it here.](https://ethproductions.github.io/japt/?v=1.4.5&code=8lYgZmogeA==&input=MgoyMw==)
[Answer]
# Ruby 1.9, 63 chars
```
require'prime';p=->a,b{Prime.each(b).select{|x|x>a}.inject(:+)}
```
Use like this
```
p[1,100] #=> 1060
```
Using the `Prime` class feels like cheating, but since the Mathematica solutions used built-in prime functions...
[Answer]
# Regex `üêá` (ECMAScript[RME](https://github.com/Davidebyzero/RegexMathEngine/) / Perl / PCRE), 32 bytes
```
^(x*),x*(?=\1)(?!(xx+)\2+$)x\Bx*
```
Takes its input in unary, as two strings of `x` characters whose lengths represent the numbers, joined by a `,` delimiter, specifying an inclusive range. Returns its output as the number of ways the regex can match. (The rabbit emoji indicates this output method.)
[Try it online!](https://tio.run/##RU@9TsMwEN79FId1g52Y1gnqUjdNi8rKxBhhlaiVUrlJSIJkFMzIA/CIvEi4ggTj93vftYfOLabzK2BnYHRNuXeAc0MwW@22D9t1YMemE9hn2qzWRo5QHQnJse2qegBe1NwEUhOKuKx/eeoHclt1nahEHp4vev7PauLlEq2hFhDoqG5DqdZVg@CKK2IMA8CSrsGpqeof9rxvR@65Rxs2Tmbvc5EvsZMiz8c4xlLpIGnx76C/EDlnHL4@PoHPsKR1b7SRhWDt3f3O2ulR@EgqH4k8KxLquhLex7JIY5S@uPXRNNEHmiVapZqlKr1hF6y/AQ "Perl 5 ‚Äì Try It Online") / [Attempt This Online!](https://ato.pxeger.com/run?1=RU89TsMwFN5zioflwU7c1gkLqpumRWVlYoywStRIQW4SklQyCmbkAKwsHeAIPUxXjsAJeCUIJuv7fZ_f3utNY_bHr-0j0EZBb6psbYBOFMJ4tlreLOfOy6uG0TaWajZXvIciR8T7uinKDkhaEuVQDTFi4nZ313bo1mIUipBvHk568s9K5PmUaoUtwKjBugWmalN0jAgikFEeAM3wGtxXRfnDbtd1TyyxVLuF4fHzhCVT2nCWJH0Q0ExIx3HxMOgvhM4xgc-XVyBjmuG6J9zoOaf11fVK649dl48ujnDLrM-F9VkSpyFWnjFrA55GAeU2vbT-4Nv_Pgf8lfRCKSLpRSI6905YDuI3 "Perl - Attempt This Online") - Perl  
[Try it online!](https://tio.run/##dVThbts2EP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APqkSpTM9SZqAi6IH1KnllbFloZd1yi1b1mOAQzXQmVVEaL42C59GUszHECZ_qR8DzR5a5qmDzJz8M4hjDMLmbnX8fJ-ED2KEDn5NoDPY4EAHWThZJLsHzgMgTm24vMajBbrWqzrRNZ-ZBxAkCqADTGxyEmHGS0p3Ondd2dQp6OiANPYsc9SwXVy0v1T8WTumJnFSK8gIR97q-wKairYSf4kJB14EinhZCmqvEsIVgZ6zczwMRznyVi71ca7SM5UUsHN0C19y_D4NPfSWZTHKGh5gvpjAVsxUFO_nMQoFWphN4D0v_8zSKGTFD8eH9aEjTcDf0MVhCHYPxqT-88kf94cXg8njUPy3F_Y-j_uVp_xR-MYKL6_PR4Hxw2XdgW0Vpfk1sbbqc6a0MR9J0o34_1NPo1YrhrdXHx30gmD_JkrmfBkKwjJMM5_7y-vzcANRt8DILthBY1nLlbTo3sGQNBTOohrKEcGqT6myavNcA2lUczaM6yE6HujWlMUvF_yplLCyyPEr4RkXldpJkoPjmuZpl5JAYuZvoqx1xR08jdcs7ULbnmQLKJSeR5i1voutnr-OqI2WxK7mEUM9rU5CeI14wd4mATnEKpVvNnvnyrIoqTXJUWPFc2nL26KO9AxybFIgkMk7NWEJLGlN31U4SJUpfwVW3T5Ga5DHHctc10A-RodoU24-9C0mODTVx4KF8tqCDXy7dd-gGjBtUarXkO67pNFfPX4Ahy28Kbel4rv3WnG509bKym7M5TgPJUVEVrLloYtWwXSoaiaHRZFTlEJSV4KvAWDxU0oXGF_yYYBaOkqogygJLjq3RWa_HVdXvsW4Prlb3JMmvx7vaBvjn198AWVNzswqv0tRMt3pB1d2u0xQ2SKXcVn9LYsC1uQu1ysngNepBG7a3jYctzxDZcHg19C-vLo5HJ2d0tSo1bioJWGQFq2HL1q7YrCRq8tvwQnz5L45CTmOMLLNY5z6tUO1p_XWiD5Feq7edjhvfu_ofqD_-6jiddqPTdrrtRtfp7jXkvq0P_wU "C++ (GCC) - Attempt This Online") - PCRE2  
[Try it on replit.com!](https://replit.com/@Davidebyzero/regex-Sum-of-primes-between-given-range) - RegexMathEngine, in ECMAScript mode
```
^              # Anchor to start
(x*)           # \1 = lower end of range
,              # Skip over delimiter
x*             # tail += {any number, including zero}
(?=\1)         # Assert that tail ‚â• \1
(?!(xx+)\2+$)  # Assert that tail is not composite (i.e., tail is prime or is < 2)
x\Bx*          # if tail ‚â• 2, add tail to the number of possible matches; this is
               # equivalent to "(?=xx)x+"
```
# Regex (.NET), 32 bytes
```
x(x*),((?=(xx+)\3+$|(x)+)x\B)*\1
```
Returns its output as the capture count of group `\4`.
[Try it online!](https://tio.run/##RY9LboMwFEXnrMJCr8KPnyDpKAg1bcddAUEVpU5w5djINsIKYdoFdIndCCWVqg7vR1fn9mpk2nRMiAV0WWl2Yq7e7SQb6T5YHHUhxpQ@lNS5CA/bCK7UYYTu8IThIV@Cfew/q3PPBXv3sYBLmRVHpVnTdhQE4ZIAl/1gcYKmBJGYXnDrx35BwJUUGnIld2QKkiCkFZe2htdEWJJhFLggrF4a260wj2/mL8UZkw/F5e8EP1I4l6DTtdd2zFBwiNPNveA0am5Z0ilj55UqL8i/QRKp1oOCS0b8lfL784vAOpWetBp6U93Xadv0dtDMpK0apEV/npc8zjMvz@JN5m3izda76ewH "PowerShell ‚Äì Try It Online")
```
                   # No need to anchor, as this regex will always match
x(x*)              # \1 = {lower end of range} - 1
                   # This takes advantage of the input specification allowing
                   # us to assume it to be ‚â• 1.
,                  # Skip over delimiter; tail = upper end of range
(
    (?=            # Lookahead - is atomic (the first match found is final)
        (xx+)\3+$  # Match if tail is composite (i.e., isn't prime and is ‚â• 2)
    |          # or...
        (x)+       # Push {tail} captures onto the Group 4 stack, i.e. add
                   # {tail} to the return value.
    )
    x              # tail -= 1
    \B             # Assert tail > 0
)*                 # Iterate the above as many times as possible (can be zero)
\1                 # Assert tail ‚â• \1
```
[Answer]
# [Pip](https://github.com/dloscutoff/pip), ~~19~~ 17 bytes
```
$+Y1=0N_%,_FIa\,b
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724ILNgwYKlpSVpuhYbVbQjDW0N_OJVdeLdPBNjdJIg4lDp5dFGOgpGxrFQLgA)
*-2 thanks to @DLosc*
Uses [DLosc's answer to the prime checker challenge](https://codegolf.stackexchange.com/a/57701/114446)
#### Explanation
```
$+Y1=0N_%,_FIa\,b  ; Input on command line
              \,   ; Inclusive range between
             a  b  ; The two inputs
           FI      ; Filtered by
   1=0N_%,_        ; Is prime (see linked answer)
$+                 ; Sum the resulting list
```
Old:
```
$+Y{1=0Na%,a}FIa,Ub  ; Input on command line
                ,    ; Range between
               a     ; The first input
                 Ub  ; To the second input incremented
             FI      ; Filtered by
   {1=0Na%,a}        ; Is prime (see linked answer)
$+Y                ¬† ; Sum the resulting list
```
[Answer]
# Factor -> 98
```
:: s ( a b -- n )
:: i ( n -- ? )
n 1 - 2 [a,b] [ n swap mod 0 > ] all? ;
a b [a,b] [ i ] filter sum ;
```
Output:
```
( scratchpad ) 100 1000 s
--- Data stack:
75067
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
√¶RS
```
[Try it online!](https://tio.run/##y0rNyan8///wsqDg////G/03MgYA "Jelly ‚Äì Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
```
≈∏Dp*O
```
[Try it online!](https://tio.run/##MzBNTDJM/f//6A6XAi3///@jDXUMDQxiAQ "05AB1E ‚Äì Try It Online")
```
≈∏      Push the list [a, ..., b]
 D     Push a duplicate of that list
  p    Replace primes with 1 and everything else with 0
   *   Element-wise multiply the two lists [1*0, 2*1, 3*1, 4*0, ...]
    O  Sum of the final list of primes
```
[Answer]
# Common Lisp, 107 chars
```
(flet((p(i)(loop for j from 2 below i never (= (mod i j) 0))))(loop for x from(read)to(read)when(p x)sum x))
```
only works for starting points \$\ge 1\$
[Answer]
# R, 57 characters
```
a=scan();b=a[1]:a[2];sum(b[rowSums(!outer(b,b,`%%`))==2])
```
[Answer]
# [Factor](https://factorcode.org/) + `math.primes math.unicode`, ~~32~~ 23 bytes
```
[ primes-between Œ£ . ]
```
*-9 bytes* thanks to [chunes](https://codegolf.stackexchange.com/users/97916/chunes)!
[Try it online!](https://tio.run/##S0tMLskv@h8a7OnnbqWQnVqUl5qjkJtYkqFXUJSZm1oMYZfmZSbnp6QqFBSllpRUAmXyShSs/0crQNToJqWWlKem5imcW6ygpxD730jBnKsgMzlbITkxJ4crOSc1seg/AA)
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~164~~ ~~138~~ 122 bytes
```
i,x,y,z;main(f){for(scanf("%d %d",&x,&y);x<y;z+=x++*!f)if(f=0,x<2)++x;else for(i=2;x/2/i&&!(f|=x%i++<1););printf("%i",z);}
```
[Try it online!](https://tio.run/##FcxbDoIwEADAqxQMTWurPH639S6kZXUTLAYwWVDPXsMBZsIljH265xOlML7jINyyRpquj1smy3azOzx7Sgr1B6dZLaFPqMoqiiqWVrKVmwZ2G@zGszHnAjWhQt9Ydp02hmEYl0EclHwHXHc1SVko/HquyBjXatDwmimtR0ul3TX8cm5F2zR/ "C (clang) ‚Äì Try It Online")
Original code from [Programiz](https://www.programiz.com/c-programming/examples/prime-number-intervals). Just modified the code to reduce bytes. Yes, I'm terrible at this.
Code changed thanks to Pedro Maimere, byte count didn't change. Thanks to ceilingcat for golfing 26 bytes, and another 16 bytes.
[Answer]
# Java 8, ~~239~~ ~~237~~ ~~74~~ 73 bytes
```
a->b->{long r=0,t;for(;a<=b;r-=b--==t?~b:0)for(t=1;b%++t%b>0;);return r;}
```
-1 byte thanks to *@ceilingcat*
[Try it online.](https://tio.run/##jU9Na4QwEL37K4aFBYMaom2hbDaWXnpqT3sUKcmuitZNJI5bROxft7G7tNdeZt58vXmvkRcZma7QzeljObay7@FN1nryAHqUWB@hcRt0wLql5aCPWBtNX25g/2p0Ff5jY41pCiUIWGSUqiidWtcCK1iIvDTW53IvFLeRUFEkBD59qR0j6wBFzNU2CHCrUsYJtwUOVoPl88I9p7IbVOtU3sReTH2CszPgH9DWuspyaauerHYAVrr1rWvudPEJV5zl05SEyd0cTnEYM@by/WOYPLB35oqZ/JwCHMYeizM1A9LOMWOr/T/fz9bKsadorl99SYLNDjZBSWXXtaMvM5aTXxznhHBHO3vz8g0)
**Explanation:**
```
a->b->{              // Method with two Long parameters & Long return-type
  long r=0,          //  Result-sum, starting at 0
       t;            //  Temp-long
  for(;a<=b          //  Loop as long as `a` is still smaller than or equal to `b`:
      ;              //    After every iteration:
       r-=           //     Decrease the result-sum by:
          b--==t?    //      If `b` is equal to `t` (which means `b` is a prime):
                     //      (and decrease `b` by 1 afterwards with `b--`)
           ~b        //       Decrease the result-sum by `-b-1`
                     //       (aka Increase the result-sum by `b+1`,
                     //        where `+1` is to account for the earlier `b--`)
          :          //      Else:
           0)        //       Leave `r` the same by decreasing with 0
    for(t=1;         //   (Re)set `t` to 1
        b%++t%b>0;); //   Increase `t` by 1 first with `++t` every iteration,
                     //   and loop as long as `b` is NOT divisible by `t`,
                     //   and `b` is NOT 1 (with the second `%b`)
  return r;}         //  After the nested loop, return the result-sum
```
[Answer]
# [Desmos](http://desmos.com/calculator), ~~124~~ 50 bytes
```
f(a,b)=‚àë_{n=a}^bnsgn((n-1)‚àè_{k=3}^nmod(n,k-1))
```
[Try it on Desmos!](https://www.desmos.com/calculator/gibosoovlc)
~~I had to waste 23 bytes just for the edge case of 0 and 1(`-\left\{n<2:1,0\right\}`). I feel like this could definitely be golfed further, but I'm not that skilled at Desmos. I especially think that the edge cases 0 and 1 could be handled a lot better than what I'm doing currently.~~
To think I've come so far... just a mere 2.5 years ago I was still a complete noob at Desmos golfing. Now, coming back to this answer 2.5 years later, there are so many golfs that I can spot. Shifting the bounds to remove the curly brackets, better ways to deal with the `n=1` edge case, and some other tiny golfs, resulted in an over 50% reduction in my original code. Truly amazing stuff.
### Explanation
I will explain each sub-expression a little out of order from the actual code, but I feel that this is the best way to understand what the code is doing.
`‚àë_{n=a}^b`: Summation from `n=a` to `b`. This will iterate through all integers between `a` and `b` inclusive.
`‚àè_{k=3}^nmod(n,k-1)`: This takes the product of `k=3` to `n` of `mod(n,k-1)`which essentially tests all the possible divisors between `k=2` and `n-1`, and checks if `n` is divisible by `k` with `mod(n,k)` (it is `mod(n,k-1)` in the actual product, which will be explained further below). If `n` is composite then at least one value of `k` will make the `mod` expression equal to `0`, making the entire product equal to `0`. Otherwise, if `n` is a prime, then the product would be a positive integer. The reason why the product goes from `k=3` to `n` instead of the more intuitive `k=2` to `n-1` is because if the upper bound is represented by more than one character, then curly brackets are required to group the characters together. In other words, a product from `k=2` to `n-1` would be `‚àè_{k=2}^{n-1}`, which is four more bytes than `‚àè_{k=3}^n`. But because we have shifted the bounds of the product up by one, we will need to subtract one from all instances of `k` in order to compensate for the shift. Hence, we have `k-1` instead of `k` in the `mod` expression. This adds two bytes to our total code length, resulting in a net -2 bytes from doing this bound shifting. Now, because the bounds start from `k=3`, what happens if `n=1` or `2`? When the upper bound is lower than the lower bound, then the product will default to a value of `1`. This is an issue for the `n=1` case, which will result in the product being a positive integer (specifically `1`), but that is undesirable because a positive integer implies that `n=1` is a prime when in reality it isn't a prime. But there is a way to easily fix this...
`(n-1)`: This expression is solely to deal with the `n=1` case. When `n=1`, `n-1` is `0` which causes the entire product to equal `0`. For any other positive value, `n-1` would simply be a positive integer and not affect the overall sign of the product. Note that this fix only works for testing primality for positive integers, but this is okay for our code because the problem specifies that `a` and `b` can be assumed to be at least `1`. To deal with the `n=0` case as well, something like `0^{0^{n-1}}` would probably work.
`nsgn( ... )`: This takes `n` and multiplies it by the sign (`sgn` in the code) of the entire product expression. Remember that if the inside expression is a positive integer, then it is a prime; otherwise, it is composite. By taking the sign of the resulting integer, we will get `1` if `n` is prime and `0` if `n` is composite. Multiplying that by `n` will give `n` and `0` for the respective possibilities.
Now considering that we are taking a summation from `n=a` to `b`, this will essentially add `n` to the total sum if `n` is a prime, but it won't contribute to the sum if `n` is a composite. In other words, it takes the sum of all integers between `n=a` and `b` which are prime. With that, we are done.
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `S`, 3 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
I≈ìP
```
#### Explanation
```
I≈ìP  # Implicit input
I    # Inclusive range, [a..b]
 ≈ì   # Filtered by:
  P  #  Primality
     # Implicit output of sum (S flag)
```
#### Screenshot
[![Screenshot](https://i.stack.imgur.com/73R9Sm.png)](https://i.stack.imgur.com/73R9S.png)
[Answer]
## Perl, 103 chars
```
while(<>){($a,$b)=split/ /;for($a..$b){next if$_==1;for$n(2..$_-1){$_=0if$_%$n==0}$t+=$_;}print"$t\n";}
```
It'll accept multiple space separated lines and give the answer for each :D
[Answer]
## In Q (95):
```
d:{sum s:{if[2=x;:x];if[1=x;:0];$[0=x mod 2;0;0=min x mod 2+til floor sqrt x;0;x]}each x+til y}
```
Sample Usage:
```
q)d[1;100]
1060
```
[Answer]
## *Mathematica*, 27
Predefined `a` and `b`:
```
a~Range~b~Select~PrimeQ//Tr
```
As a function (also 27):
```
Tr[Range@##~Select~PrimeQ]&
```
[Answer]
## Python 3.1(153 chars):
```
from sys import*
p=[]
for i in range(int(argv[1]),int(argv[2])):
 r=1
 for j in range(2,int(argv[2])):
  if i%j==0and i!=j:r=0
 if r:p+=[i]
print(sum(p))
```
]