[Question]
  [
# Most of us know...
that all primes `p>3` are of the form [![enter image description here](https://i.stack.imgur.com/3EjFI.gif)](https://i.stack.imgur.com/3EjFI.gif)
But, how many are the **Plus Primes** (`6n+1`) and how many are the **Minus Primes** (`6n-1`) in a certain range?
# The Challenge
Given an integer `k>5` , count how many `primes<=k` are **PlusPrimes** and how many are **MinusPrimes**.
# Examples
for `k=100` we have  
`[5, 11, 17, 23, 29, 41, 47, 53, 59, 71, 83, 89]` **12 MinusPrimes**  
and  
`[7, 13, 19, 31, 37, 43, 61, 67, 73, 79, 97]` **11 PlusPrimes**
for `k=149` we have  
`[5, 11, 17, 23, 29, 41, 47, 53, 59, 71, 83, 89, 101, 107, 113, 131, 137, 149]`  
**18 MinusPrimes**  
and  
`[7, 13, 19, 31, 37, 43, 61, 67, 73, 79, 97, 103, 109, 127, 139]`  
**15 PlusPrimes**
# Rules
Your code must output **2 integers**: one for the **MinusPrimes** and one for the **PlusPrimes** in any order you like (please specify which is which).  
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"): shortest answer in bytes wins!
# Test Cases
> 
> **Input** -> **Output** [**MinusPrimes**,**PlusPrimes**]
> 
> 
> 
```
6->[1,0]  
7->[1,1]   
86->[11,10]  
986->[86,78]  
5252->[351,344]  
100000->[4806,4784]   
4000000->[141696, 141448]
```
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~10~~ 9 bytes
Saved 1 byte thanks to *Erik the Outgolfer*
Outputs as `[PlusPrimes, MinusPrimes]` 
```
LDpÏ6%5Ñ¢
```
[Try it online!](https://tio.run/##MzBNTDJM/f/fx6XgcL@ZqunhiYcW/f9vYQYA "05AB1E – Try It Online")
or as a [Test Suite](https://tio.run/##MzBNTDJM/V9TVvnfx6XgcL@ZqunhiYcW/a9UOrzfSuHwfiWd/2Zc5lwWZlyWQGxqZGrEZWgAAgA)
**Explanation**
```
L             # push range [1 ... input]
 DpÏ          # keep only primes
    6%        # mod each by 6
      5Ñ      # divisors of 5 [1, 5]
        ¢     # count
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 10 bytes
```
Zq6\!5lh=s
```
[Try it online!](https://tio.run/##y00syfn/P6rQLEbRNCfDtvj/fxMDMAAA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##y00syfmf8D@q0CxG0TQnw7b4v0vIfzMucy4LMy5LIDY1MjXiMjQAAS4TMGUAAA).
### Explanation
```
Zq     % Implicitly input k. Push row vector of primes up to k
6\     % Modulo 6, element-wise
!      % Transpose into a column vector
5lh    % Push row vector [5, 1]
=      % Is equal?, element-wise with broadcast
s      % Sum of each column. Implicitly display
```
[Answer]
# [Python 2](https://docs.python.org/2/), 77 bytes
-2 bytes thanks to Neil  
```
lambda x:[sum(all(n%j for j in range(2,n))for n in range(i,x,6))for i in 7,5]
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCKrq4NFcjMSdHI081SyEtv0ghSyEzT6EoMS89VcNIJ09TEySWhxDL1KnQMYOIZoJEzXVMY/8XFGXmlSikaZhpcsGYFkhsS2SOqZGpkeZ/AA "Python 2 – Try It Online")
### Previous solution, ~~83~~ ~~81~~ 79 bytes
-1 byte thanks to Mr. Xcoder  
-2 bytes thanks to Halvard Hummel 
```
lambda x:map([all(n%i for i in range(2,n))*n%6for n in range(4,x)].count,[5,1])
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCKjexQCM6MSdHI081UyEtv0ghUyEzT6EoMS89VcNIJ09TUytP1QwknocQN9Gp0IzVS84vzSvRiTbVMYzV/F9QlJlXopCmYabJBWNaILEtkTmmRqZGmv8B "Python 2 – Try It Online")  
Both output as [MinusPrimes,PlusPrimes]
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
s6ÆPSm4
```
Plus, then minus.
[Try it online!](https://tio.run/##y0rNyan8/7/Y7HBbQHCuyf/D7Y@a1rj//2@mo2Cuo2ABpCxBhKmRqZGOgqEBCAAA "Jelly – Try It Online")
### How it works
```
s6ÆPSm4  Main link. Argument: n
s6       Split [1, ..., n] into chunks of length 6.
  ÆP     Test all integers for primality.
    S    Sum across columns.
         This counts the primes of the form 6k + c for c = 1, ..., 6.
     m4  Take every 4th element, leaving the counts for 6k + 1 and 6k + 5.
```
[Answer]
# Mathematica, 51 bytes
```
(s=#;Mod[Prime~Array~PrimePi@s,6]~Count~#&/@{5,1})&
```
[Try it online!](https://tio.run/##y00sychMLv6fZvtfo9hW2do3PyU6oCgzN7XOsagosbIOzA7IdCjWMYutc84vzSupU1bTd6g21TGs1VT7D5TOK1FwSIs2i@WCs82R2BbIEpYg3v//AA "Mathics – Try It Online")
@ngenisis golfed it down, saving 4 bytes
# Mathematica, 47 bytes
```
sPrime~Array~PrimePi@s~Mod~6~Count~#&/@{5,1}
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt/), ~~15~~ ~~13~~ 11 bytes
Output order is `[+,-]`.
```
õj ò6 yx ë4
```
[Test it](https://ethproductions.github.io/japt/?v=1.4.5&code=9Wog8jYgeXgg6zQ=&input=MTQ5Ci1R)
* Took some inspiration from [Dennis' Jelly solution](https://codegolf.stackexchange.com/a/140960/58974) but, after golfing, it's closer to being a port.
* 2 bytes saved thank to Oliver bringing the previously-unknown-to-me `ë` method for arrays to my attention.
---
## Explanation
Implicit input of integer `U`.
```
õj
```
Generate an array of integers (`õ`) from 1 to `U` and check if each is a prime (`j`), giving an array of booleans.
```
ò6
```
Partition the array into sub-arrays of length 6.
```
yx
```
Transpose (`y`) and sum the columns.
```
ë4
```
Get every 4th element of the array and implicitly output them.
---
## Original, ~~19~~ ~~17~~ ~~16~~ 15 bytes
```
õ fj
5â £è_%6¥X
```
[Test it](https://ethproductions.github.io/japt/?v=1.4.5&code=9SBmagpGcyCso+hfJTalWA==&input=MTQ5)
* 1 byte thanks to an inspired suggestion from Oliver to use the divisors of 5 after I'd rested on my laurels splitting 15 to an array.
[Answer]
# [J](http://jsoftware.com/), 23 bytes
```
1#.5 1=/6|_1 p:@i.@p:>:
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6zkE6Pm7/DZX1TBUMbfXNauINFQqsHDL1HAqs7Kz@a3KlJmfkK6QpmMEYFnCWJYJpaAACMJ4JmGfwHwA "J – Try It Online")
```
1#.5 1=/6|_1 p:@i.@p:>:   input: y
          _1       p:     number of primes
                     >:   less than y + 1
             p:@i.        prime range from 0 to that number
        6|                get residues modulo 6
   5 1=/                  table of values equal to 5 or 1
1#.                       sum of each (antibase 1)
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~53~~ 51 bytes
```
.+
$*
1
$`1¶
G`1111
A`^(11+)\1+$
1{6}
*M`111
\b1\b
```
[Try it online!](https://tio.run/##K0otycxL/P9fT5tLRYvLkEslwfDQNi73BEMg4HJMiNMwNNTWjDHUVuEyrDar5eLS8gVJccUkGcYk/f9vaGIJAA "Retina – Try It Online") Explanation:
```
.+
$*
```
Convert to unary.
```
1
$`1¶
```
Count from 1 up to `n`.
```
G`1111
```
Delete numbers less than 4.
```
A`^(11+)\1+$
```
Delete composite numbers.
```
1{6}
```
Take the remainder modulo 6.
```
*M`111
```
Print the number of numbers with a remainder between 3 and 5.
```
\b1\b
```
Print the number of numbers with a remainder of 1.
[Answer]
# Ruby, ~~61~~ 60 bytes
## (52 bytes + 8 for the `-rprimes` flag)
```
->n{[1,5].map{|x|(4..n).count{|i|i.prime?&&i%6==x}}}
```
Returns an array of the form [plus primes, minus primes].
Saved 1 byte thanks to G B!
[Try it online.](https://tio.run/##KypNqvyfZvtf1y6vOtpQxzRWLzexoLqmokbDRE8vT1MvOb80r6S6JrMmU6@gKDM31V5NLVPVzNa2ora29n@BQlq0WSwXiDKHUBZQrqGBAZRhYglhWMKkTI1MjeCKDGDqTAwgnP//8gtKMvPziv/rFoEtBAA)
[Answer]
# [Perl 6](https://perl6.org), 42 bytes
*Saved 1 byte by removing a useless space...*
*Saved 2 bytes by reorganizing the* `map` *call — thanks to @Joshua.*
*Saved 3 bytes because* `.round` *equals* `.round: 1`.
*Actually the complex exponential is cool but very expensive characterwise. Saved 10 bytes just by ditching it...*
```
{[+] map {.is-prime*($_%6-1??i!!1)},5..$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJKmYPu/Olo7ViE3sUChWi@zWLegKDM3VUtDJV7VTNfQ3j5TUdFQs1bHVE9PJb72vzWXhpmOgrmOggWQsgQRpkamRpp6QN1WCtUqaUBtmnrFiZW11v8B "Perl 6 – Try It Online")
This was the version with the complex exponential. (I like it too much to delete it.) The new version works exactly in the same way, just the complex exponential is replaced by the much shorter ternary operator.
```
{[+] map {.is-prime*exp(π*($_%6-1)i/8).round},5..$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJKmYPu/Olo7ViE3sUChWi@zWLegKDM3VSu1okDjfIOWhkq8qpmuoWamvoWmXlF@aV5KrY6pnp5KfO1/ay4NMx0Fcx0FCyBlCSJMjUyNNPWABlkpVKukAbVq6hUnVtZa/wcA "Perl 6 – Try It Online")
The output is a complex number `(PlusPrimes) + (MinusPrimes)i`. I hope it's not too much against the rules.
---
Explanation: It's a function that takes one integer argument. We iterate over all integers from 5 to the argument (`(5..$_)`). For each of these, we evaluate `.is-prime` (this is called on `$_`, the argument of the mapped block), multiply it (if numified, `True == 1, False == 0`) with a complex exponential that's made to be either `exp(0) = 1` (for `$_%6 = 1`) or `exp(iπ/2) = i` (for `$_%6 = 5`), and finally round it to the nearest integer. Summing them up with `[+]` gives the result.
Finally: it's really efficient, so I'm not sure if TIO won't time out before you get your output for higher numbers (for 1e5, it takes 26 sec on my machine, and TIO tends to be somewhat slower).
[Answer]
# [Actually](https://github.com/Mego/Seriously), 21 bytes
```
u5x`p░⌠6@%1=;`╖*ƒ⌡Ml╜
```
[Try it online!](https://tio.run/##AS8A0P9hY3R1YWxsef//dTV4YHDilpHijKA2QCUxPTtg4pWWKsaS4oyhTWzilZz//zEwMA "Actually – Try It Online")
Outputs the PlusPrimes first, followed by the MinusPrimes
Explanation:
```
u5x`p░⌠6@%1=;`╖*ƒ⌡Ml╜
u5x                    range(5, n+1)
   `p░                 primes in range
      ⌠6@%1=;`╖*ƒ⌡M    for each prime:
       6@%               mod 6
          1=             equal to 1
            ;`╖*ƒ        execute ╖ if p%6==1 (add 1 to register 0, consuming p)
                   l   length of resulting list (MinusPrimes)
                    ╜  push value in register 0 (PlusPrimes)
```
[Answer]
# [Stacked](https://github.com/ConorOBrien-Foxx/stacked), 37 bytes
```
[~>$primeYES 6%5 1,$=table tr$summap]
```
[Try it online!](https://tio.run/##Ky5JTM5OTfn/P7rOTqWgKDM3NdI1WMFM1VTBUEfFtiQxKSdVoaRIpbg0NzexIPa/g1UaF5eGmYK5goWZgiUQmxqZGmkqRHMpAIG6Q2aKrl20Q1qsuqJCfmkJV6wCUNN/AA "Stacked – Try It Online")
Rather slow, tests for primality for each **K** < **N**. Works similar to my J answer.
[Answer]
# MATLAB 2017a, 29 Bytes
```
sum(mod(primes(k),6)'==[5,1])
```
Explanation: `primes(k)` gets all primes up to and including k. `mod(primes(k),6)'` takes the modulus 6 of all primes and transposes it so the sum runs along the correct dimension. `==[5,1]` sets all fives (minusPrimes) to 1 in the first column and all ones (plusPrimes) to 1 in the second column. `sum()` sums each column.
This outputs `[minusPrime, plusPrime]`
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~18~~ 16 bytes
*-2 bytes thanks to @Oliver*
```
õ_j ©Z%6
5â £è¥X
```
[Try it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=9V9qIKlaJTYKNeIgo+ilWA==&input=Nw==)
Outputs in the format `[PlusPrimes, MinusPrimes]`.
[Answer]
# C#, ~~202~~ ~~179~~ 174 Bytes
*-23 Bytes thanks to Mr. Xcoder*
*-5 Bytes thanks to Cyoce*
Function that returns an array of length 2, `[MinusPrimes, PlusPrimes]`
Execute by calling `a(n)`.
```
int[]a(int n){int[]r={0,0};for(int i=5;i<=n;i++)if(i%2*b(i)>0)if(i%6<5)r[1]++;else++r[0];return r;}int b(int n){for(int i=3;i-2<Math.Sqrt(n);i+=2)if(n%i<1)return 0;return 1;}
```
Properly formatted code on Try It Online: [Here](http://jdoodle.com/a/5UP)
[Answer]
# [Haskell](https://www.haskell.org/), ~~81~~ 69 bytes
```
f n=(\r->sum[1|i<-[2..n],all((>0).rem i)[2..i-1],rem i 6==r])<$>[5,1]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00hz1YjpkjXrrg0N9qwJtNGN9pITy8vVicxJ0dDw85AU68oNVchUxMkmqlrGKsD5iqY2doWxWraqNhFm@oYxv7PTczMU7BVSMnn4iwoyswrUVBRSFMwQ@aYI3MsUKQsUbmmRqZG/wE "Haskell – Try It Online")
First solution was:
```
r!l=sum[1|i<-l,rem i 6==r]
f n|l<-[i|i<-[2..n],all((>0).rem i)[2..i-1]]=(5!l,1!l)
```
But I read w0lf's answer in Ruby...
[Answer]
# [Pyth](https://pyth.readthedocs.io), 15 bytes
```
/K%R6fP_TSQ5/K1
```
**[Test Suite.](https://pyth.herokuapp.com/?code=%2FK%25R6fP_TSQ5%2FK1&input=986&test_suite=1&test_suite_input=6%0A86%0A986%0A5252&debug=0)**
# [Pyth](https://pyth.readthedocs.io), 16 bytes
```
m/%R6fP_TSQd,1 5
```
**[Test Suite.](https://pyth.herokuapp.com/?code=m%2F%25R6fP_TSQd%2C1+5&input=986&test_suite=1&test_suite_input=6%0A86%0A986%0A5252&debug=0)**
---
# How?
### Explanation #1
```
/K%R6fP_TSQ5/K1 - Full program.
     fP_TSQ     - Filter the primes in the range [1...input].
  %R6           - Mod 6 on each.
 K              - Assign them to a variable K.
/          5    - Count the occurrences of 5 in K.
            /K1 - Count the occurrences of 1 in K.
                - Implicitly output the result.
```
### Explanation #2
```
m/%R6fP_TSQd,1 5 - Full program.
     fP_TSQ      - Filter the primes in the range [1...input]
  %R6            - Mod 6 on each.
            ,1 5 - Push the list [1, 5]
m/         d     - Count how many of each there are.  
                 - Implicitly output the result. 
```
Alternatives:
```
/K%R6fP_TSQ5/KhZ    (16 bytes)
K%R6fP_TSQ/K5/K1    (16 bytes)
m/%R6fP_TSQdj15T    (16 bytes)
m/%R6fP_TSQd[1 5    (16 bytes)   
m/%R6fP_TSQdsM`15   (17 bytes)
m/%R6.MP_ZSQd,1 5   (17 bytes)
m/%R6.MP_ZSQdj15T   (17 bytes)
m/%R6.MP_ZSQd[1 5   (17 bytes)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~12 11~~ 10 bytes
Thanks to [@cairdcoinheringaahing](https://codegolf.stackexchange.com/users/66833/caird-coinheringaahing) for some tips in chat. Thanks to [@Dennis](https://codegolf.stackexchange.com/users/12012/dennis?tab=profile) for saving one byte in chat.
```
ÆR%6ċÐ€1,5
```
[Try it online!](https://tio.run/##y0rNyan8//9wW5Cq2ZHuwxMeNa0x1DH9//@/hRkA "Jelly – Try It Online")
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
ÆR%6µ1,5=þS
```
[Try it online!](https://tio.run/##y0rNyan8//9wW5Cq2aGthjqmtof3Bf///9/CDAA "Jelly – Try It Online")
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
ÆR%6µċ5,ċ1$
```
[Try it online!](https://tio.run/##y0rNyan8//9wW5Cq2aGtR7pNdY50G6r8///fwgwA "Jelly – Try It Online")
---
# How does this work?
### Explanation #1
```
ÆR%6ċÐ€1,5   As usual, full program.
ÆR           Get all the primes in the range [2...input].
  %6         Modulo each by 6.
       1,5   The two-element list [1, 5].
    ċÐ€      Count the occurrences of each of ^ in the prime range.
```
### Explanation #2
```
ÆR%6µ1,5=þS   As usual, full program.
ÆR            Get all the primes in the range [2...input].
  %6          Modulo each by 6.
    µ         Chain separator.
     1,5      The two-element list [1, 5].
        =     Equals?   
         þ    Outer product.     
          S   Sum.
```
### Explanation #3
```
ÆR%6µċ5,ċ1$   As usual, full program.
ÆR            All the primes in the range [2...input].
  %6          Modulo each by 6.
    µ     $   Some helpers for the chains.
       ,      Two element list.
     ċ5       The number of 5s.
        ċ1    The number of 1s.
```
[Answer]
# Java 8, ~~141~~ ~~140~~ ~~138~~ ~~106~~ ~~101~~ ~~100~~ ~~96~~ ~~94~~ 81 bytes
```
n->{int r[]={0,0},c;for(;n-->4;r[n%6/4]+=c)for(c=n;c>1;c=c-1&~n%c>>-1);return r;}
```
Returns an integer-array with two values, in reversed order compared to the challenge description:  
`[plusPrime, minusPrime]`.
Port of [*@Xynos*' C# answer](https://codegolf.stackexchange.com/a/140937/52210), after I golfed ~~39~~ ~~40~~ 42 bytes.  
Huge help from *@Nevay* for another whopping -55 bytes.
**Explanation:**
[Try it here.](https://tio.run/##lY9BboMwEEX3nGI2iUwBFyKStnKN1AM0mywRC8ch1bhgkDGRIsTZqQlddFksWyP/maf/R4mbiJq21OryPWHdNsaCchrtLVb0wxhx75gnK9F18ClQDx4Aaluaq5AlHOfvQ8gLkMRV0D5z2uieu50VFiUcQQOHSUfZMI@YvOBDHMZjiDwNVSjZtTGEYRC8a2Zy3Bye0yLguJX@3FBc8oSpJ@X6yHy55RFugkBlWZQwU9reaDBsnNji2fbnynn@Wt8avEDtgpOTNai/XE7hL6lP986WNW16S1vXspUmy77UNssw0VSSg@8/Vvo38LIWeF1t8bYe2e/2u7VMEs9nLZXGf7HRG6cf) (Final test case of `4000000` is exceeding the 60 sec time limit slightly.)
```
n->{                   // Method with integer parameter and integer-array return-type
  int r[]={0,0},       //  Return integer-array, starting at [0,0]
      c;               //  Temp integer
  for(;n-->4;          //  Loop (1) as long as the input is larger than 4
                       //  and decrease `n` by 1 before every iteration
      r[n%6/4]+=c)     //    After every iteration, increase the plus or minus prime by `c`
                       //    (where `c` is either 0 or 1)
    for(c=n;           //   Reset `c` to `n`
        c>1;           //   And inner loop (2) as long as `c` is larger than 1
      c=               //    Change `c` to:
        c-1&~n%c>>-1;  //     inverting the bits of `n`,                    [~n]
                       //     modulo-`c` that result,                       [%c]
                       //     then bit-shift right that by -1,              [>>-1]
                       //     and then bitwise-AND that result with `c-1`   [c-1&]
    );                 //   End of inner loop (2)
                       //  End of loop (1) (implicit / single-line body)
  return r;            //  Return result integer-array
}                      // End of method
```
[Answer]
# JavaScript (ES6), ~~83~~ ~~82~~ ~~80~~ ~~68~~ 66 bytes
Turned out a fully recursive solution was *much* shorter than mapping an array!
Output order is `[-,+]`. Craps out with an overflow error somewhere around 3490.
```
f=(n,a=[0,0])=>n>4?f(n-1,a,(g=y=>n%--y?g(y):y<2)(n)&&++a[n%6%5]):a
```
---
## Try it
```
o.innerText=(
f=(n,a=[0,0])=>n>4?f(n-1,a,(g=y=>n%--y?g(y):y<2)(n)&&++a[n%6%5]):a
)(i.value=6);oninput=_=>o.innerText=i.value>5?f(+i.value):[0,0]
```
```
<input id=i min=6 type=number><pre id=o>
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 19 bytes
```
ri){mp},6f%_5e=p1e=
```
Program that takes the input from STDIN, and outputs the two numbers separated by newline through STDOUT.
[**Try it online!**](https://tio.run/##S85KzP3/vyhTszq3oFbHLE013jTVtsAw1fb/f0MDEAAA "CJam – Try It Online")
### Explanation
```
ri){mp},6f%_5e=p1e=
ri                        Read integer k
  )                       Add 1
       ,                  Filter the (implicit) array [0 1 ... k] ...
   {mp}                   ... on the function "is prime"
         f                Map over the resulting array...
          %               ... the function "modulus" ...
        6                 ... with extra parameter 6
           _              Duplicate the resulting array
             e=           Count occurrences ...
            5             ... of number 5
               p          Print with newline
                 e=       Count occurrences ...
                1         ... of number 1. Implicitly display
```
[Answer]
# [R](https://www.r-project.org/) + [numbers](https://cran.r-project.org/web/packages/numbers/numbers.pdf), ~~66~~ ~~60~~ ~~58~~ 40 bytes
*-16 bytes thanks to Jarko Dubbeldam!* I subsequently golfed another two bytes off.
```
cat(table(numbers::Primes(4,scan())%%6))
```
Prints `PlusPrimes MinusPrimes` to stdout; reads from stdin.
`table` tabulates the count of each occurrence of the values in its input vector, in ascending order of value. Hence, since there are only two values, namely `1` and `5` (mod 6), this is exactly the function we need, along with `numbers::Primes`, which returns all primes between `4` and the input.
[Try it online!](https://tio.run/##K/r/PzmxRKMkMSknVSOvNDcptajYyiqgKDM3tVjDRKc4OTFPQ1NTVdVMU/O/oYnlfwA)
# Base [R](https://www.r-project.org/), ~~97~~ ~~91~~ ~~89~~ ~~86~~ 65 bytes
*a bunch of bytes saved by Jarko here, too*
```
function(n)table((5:n)[sapply(5:n,function(x)all(x%%2:x^.5))]%%6)
```
This is nearly identical to the above, except it calculates all the primes in base R rather than using a package, and it returns by function output rather than printing it out. You can see in the output that it returns a table with names `1` and `5`, with the counts below.
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jT7MkMSknVUPD1CpPM7o4saAgpxLE1oGrqNBMzMnRqFBVNbKqiNMz1dSMVVU10/yfpmGuyZWmYWhiqfkfAA "R – Try It Online")
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 41 bytes
```
n->vecsum([[i>3,i<3]|i<-primes([4,n])%6])
```
[Try it online!](https://tio.run/##K0gsytRNL/ifpmCr8D9P164sNbm4NFcjOjrTzlgn08Y4tibTRregKDM3tVgj2kQnL1ZT1SxW839iQUFOpUaegq6dAlAyrwTIVAJxlBTSNPI0NXUUos10FMx1FCyAlCWIMDUyNdJRMDQAAaB@AA "Pari/GP – Try It Online")
[Answer]
# [JavaScript (SpiderMonkey)](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/45), ~~151~~, ~~140~~, 131 bytes
```
n=>[...Array(n+1).keys()].splice(5).filter(a=>!/^1?$|^(11+?)\1+$/.test("1".repeat(a))).reduce((r,a)=>(a%6<2?r[1]++:r[0]++,r),[0,0])
```
[Try it online!](https://tio.run/##DYzBCoJAFEW/JSl4j7GnExUUqbRtUYuWpjDYGFM2ypspEPp3m9U9cDj3qb7KNWwGv3SDuWt@9/alx6nNJpvlJREdmdUIVkikIBxgRW7oTKNhg9SazmsGleWzpJbF/FeDlKLAmxTzhLx2HiIZEetBKw8KEQPfPyEGjhVmOajF9rAquJSVEHsu0zAxY1ymcVrh1PTW9Z2mrn/A6Xo5k/Ns7MO0I7Qg17twOP0B "JavaScript (SpiderMonkey) – Try It Online")
Thanks to shaggy for helping with a bug fix and golfing.
Explanation:
```
n=>                                                   // Create a lambda, taking n
    [...Array(n+1).keys()]                            // Create a list from 0 to n+1
        .splice(5)                                    // remove first five elements
        .filter(a=>                                   // filter the list to get primes
             !/^1?$|^(11+?)\1+$/.test("1".repeat(a))) // using the famous regex here: https://stackoverflow.com/questions/2795065/how-to-determine-if-a-number-is-a-prime-with-regex 
        .reduce((r,a)=>                               // reduce the list
           (a%6<2?r[1]++:r[0]++,r),                   // by counting plus primes
           [0,0])                                     // and minus primes
```
]