[Question]
  [
# How many petals around the rose
How many petals around the rose is a dice game you can play with your friends. Similar to ["can I join the music box"](https://codegolf.stackexchange.com/q/199153/75323), there is a person that knows how the game works and the others have to discover the rule.
In this game, someone rolls some dice (usually two or more) and then people have to call "how many petals are around the rose".
# Algorithm
If you want to play it by yourself, you can [play it over at TIO](https://tio.run/##Zc49CoAwDAXg3VO8sVUH8WcRehjBFAvSlrQOnr5aFRGcQr73AvF7XJzt0kwanuK0BlGyCxTkWOARKDTnoh0jRzD2miE3AKNvVQrdLe9dpdBeQuunNfxb/SlMcWP7YPJsbBTvC2Ko0ctCpnQA). Just hide the header (which is where the rule is implemented) and try passing different arguments (from 1 to 6) in the function.
**spoiler, what follows *is* the rule you are invited to find by yourself!**
> 
>  The "roses" here are the dice, and the "petals" are the black dots that are *around* a central dot. Because only the odd numbers have a central black dot, only numbers `1, 3, 5` matter for the petals. Those numbers have, respectively, `0, 2, 4` dots around the central dot, the "petals".
> 
> 
> 
[![enter image description here](https://i.stack.imgur.com/xuMCB.jpg)](https://i.stack.imgur.com/xuMCB.jpg)
# Input
Your input will be a non-empty list (or equivalent) of integers in the range `[1, 6]`.
# Output
The number of petals around the rose.
# Test cases
[Reference implementation](https://tio.run/##Zc49CoAwDAXg3VO8sVUH8WcRehjBFAvSlrQOnr5aFRGcQr73AvF7XJzt0kwanuK0BlGyCxTkWOARKDTnoh0jRzD2miE3AKNvVQrdLe9dpdBeQuunNfxb/SlMcWP7YPJsbBTvC2Ko0ctCpnQA) in Python, that also generated the test cases.
```
1, 1 -> 0
1, 2 -> 0
1, 3 -> 2
1, 4 -> 0
1, 5 -> 4
1, 6 -> 0
2, 1 -> 0
2, 2 -> 0
2, 3 -> 2
2, 4 -> 0
2, 5 -> 4
2, 6 -> 0
3, 1 -> 2
3, 2 -> 2
3, 3 -> 4
3, 4 -> 2
3, 5 -> 6
3, 6 -> 2
4, 1 -> 0
4, 2 -> 0
4, 3 -> 2
4, 4 -> 0
4, 5 -> 4
4, 6 -> 0
5, 1 -> 4
5, 2 -> 4
5, 3 -> 6
5, 4 -> 4
5, 5 -> 8
5, 6 -> 4
6, 1 -> 0
6, 2 -> 0
6, 3 -> 2
6, 4 -> 0
6, 5 -> 4
6, 6 -> 0
3, 1, 5 -> 6
4, 5, 2 -> 4
4, 3, 5 -> 6
1, 4, 4 -> 0
5, 5, 2 -> 8
4, 1, 1 -> 0
3, 4, 1 -> 2
4, 3, 5 -> 6
4, 4, 5 -> 4
4, 2, 1 -> 0
3, 5, 5, 2 -> 10
6, 1, 4, 6, 3 -> 2
3, 2, 2, 1, 2, 3 -> 4
3, 6, 1, 2, 5, 2, 5 -> 10
```
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!
  
[Answer]
# [Python 3](https://docs.python.org/3/), 30 bytes
```
lambda l:sum(n**3&6for n in l)
```
[Try it online!](https://tio.run/##XZPBboMwEETvfIXFoYKISmVtVlEkeuwX9JbmQBujRCIQgSO1Qnw7xVh2p1yQh7Fn3y74/mMuXSvnuvyYm@r2ea5Ecxget6Td7eQT110vWnFtRZPORg9mKJMoOeaZyE@ZeEkzJwiFXAR5odApFqG84OAQphGmEaYRphGmEaZJl0ZeEAoZzkiXFhybxl5wcBSyKWRTyKaQTSGbQrbCpSkvCIUMBIVLC45N23vBwWFkY2RjZGNkY2RjZOPtEHEmtiXEtc2jb780linC/n0YI9LKdX@O85Obetsp0ub8X4k8NOAw/nUv15O0erT5Adi/LdzTZ6VRX47v/UMf4mqIM/FWNcOybjsjFj1F9lKYTNtrsd6JQyTu/bU1SR2PZhLPr2KsE5NOYuyPdlGW@jQJ/X3XX0af43T@BQ "Python 3 – Try It Online")
(test cases shamelessly borrowed from [xnor's answer](https://codegolf.stackexchange.com/a/200407/58563))
### How?
Given \$1\le n\le6\$, the number of petals can be computed with:
$$p=n^{2k+1} \operatorname{and}6,\:k\in\mathbb{N}^\*$$
where \$\operatorname{and}\$ is a bitwise operator.
This can also be written as:
$$p=2\times\left\lfloor\frac{n^{2k+1}\bmod 8}{2}\right\rfloor$$
And is based on the fact that, for any \$k\ge1\$:
$$n^{2k+1}\bmod 8=\cases{
n&\text{if $n$ is odd ($1$, $3$ or $5$)}\\
0&\text{if $n$ is even ($2$, $4$ or $6$)}
}$$
More specifically, choosing \$k=1\$:
$$p=n^3 \operatorname{and}6$$
As Python code, the resulting expression is just as long as the nice `n%-2%n` [found by xnor](https://codegolf.stackexchange.com/a/200407/58563). But because it ends with a digit, we can get rid of the space just before the `for`, saving a byte.
```
 n | n**3 | as binary  | AND 6
---+------+------------+-------
 1 |    1 | 00000 **00** 1 |   0
 2 |    8 | 00001 **00** 0 |   0
 3 |   27 | 00011 **01** 1 |   2
 4 |   64 | 01000 **00** 0 |   0
 5 |  125 | 01111 **10** 1 |   4
 6 |  216 | 11011 **00** 0 |   0
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 11 bytes
```
5
33
3
33
3
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7w35TL2JjLGEz8/29samrEZWZoYgbkGRkZGgEpM0MjUyNTAA "Retina 0.8.2 – Try It Online") Link includes test cases. Input can be in almost any format really as only the `5`s and `3`s count. Explanation:
```
5
33
```
A `5` has as many petals as two `3`s.
```
3
33
```
Speaking of `3`s, they have two petals, so make them count twice.
```
3
```
Count the petals.
[Answer]
# [Python](https://docs.python.org/3/), 31 bytes
```
lambda l:sum(n%-2%n for n in l)
```
[Try it online!](https://tio.run/##XZNRa4MwFIXf/RUXoaBgYd7EUArucb9gb10f3BZZwaZFU9gQf7szhmRnvkiOJzn3u1dz/7FfNyPmtn6bu@b6/tlQdxwe18zs9rwz1N56MnQx1OWz1YMd6izJTmVB5bmgp7zwglGIRXAQEp1qETIIFR3GNMY0xjTGNMY0xjTh0zgIRiHiGeHTouPSVBAqOhLZJLJJZJPIJpFNIlvl02QQjEJEgsqnRcelHYJQ0VHIppBNIZtCNoVsCtnUdog4E9cS4rrm0XdfGstUcf8hjhFpxbq/xPmJTb3tFHlz/q9EGRvwGP@6F@tJXj3e/AAqvK38M2TlSV@Pr/1DH9NmSAt6abphWZubpUVPibsUttDuWqx34pjQvb8Ym7XpaCfaP9PYZjafaOxPblHX@jyR/r7rD6s/03z@BQ "Python 3 – Try It Online")
The core expression `n%-2%n` evaluates to zero for even `n` and to `n-1` for odd `n`. 
```
       | n%-2   n%-2%n
-------+--------------
n even |    0        0  
n odd  |   -1      n-1
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 4 bytes
-3 using [Giuseppe's method](https://codegolf.stackexchange.com/a/200387/53748)!
```
Ḃ×’S
```
**[Try it online!](https://tio.run/##y0rNyan8///hjqbD0x81zAz@//9/tLGOgpmOgqGOgpGOgimEjAUA "Jelly – Try It Online")**
### How?
We know that 3's and 5's "score", that they score one less than their pips, and that \$1-1=0\$ so:
```
        throw   1  2  3  4  5  6
  x=throw - 1   0  1  2  3  4  5
  y=throw % 2   1  0  1  0  1  0
score = x * y   0  0  2  0  4  0
```
So:
```
Ḃ×’S - Link: throws, list of integers in [1,6]   e.g. [1,2,3,4,5,6]
Ḃ    - (throws) % 2                                   [1,0,1,0,1,0]
  ’  - (throws) - 1                                   [0,1,2,3,4,5]
 ×   - multiply                                       [0,0,2,0,4,0]
   S - sum                                            6
```
[Answer]
# [R](https://www.r-project.org/), ~~26~~ 23 bytes
```
function(l)l%%2%*%(l-1)
```
[Try it online!](https://tio.run/##K/qfpmCj@z@tNC@5JDM/TyNHM0dV1UhVS1UjR9dQ83@aRrKGsY6CERgZgkljTc3/AA "R – Try It Online")
*-3 thanks to [Robin Ryder](https://codegolf.stackexchange.com/users/86301/robin-ryder)!*
Returns a 1x1 matrix with the result.
---
Old answer, since there are a handful of explicit ports:
```
function(l)sum((l-1)*l%%2)
```
[Try it online!](https://tio.run/##K/qfpmCj@z@tNC@5JDM/TyNHs7g0V0MjR9dQUytHVdVI83@aRrKGsY6CERgZgkljTc3/AA "R – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~17~~ 16 bytes
```
{sum $_>>³X+&6}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/urg0V0El3s7u0OYIbTWz2v/WXMWJlQppCtHGOgpmOgqGOgpGOgqmEDL2PwA "Perl 6 – Try It Online")
Uses [Arnauld's formula](https://codegolf.stackexchange.com/a/200429/76162) of \$n^3\&6\$. If HyperWhatevers worked, then something like `(**³+&6).sum` should be possible for 13 bytes.
My old regex based solution:
```
{sum m:g/3|5/X-1}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/urg0VyHXKl3fuMZUP0LXsPa/NVdxYqVCmkK0sY6CmY6CoY6CkY6CKYSM/Q8A "Perl 6 – Try It Online")
Match 3s and 5s from the input, subtract one from each and sum them together.
[Answer]
# [Python](https://docs.python.org), 32 bytes
```
lambda d:sum(r%2*~-r for r in d)
```
Port of [Giuseppe's R answer](https://codegolf.stackexchange.com/a/200387/53748).
**[Try it online!](https://tio.run/##K6gsycjPM7YoKPqfZhvzPycxNyklUSHFqrg0V6NI1UirTrdIIS2/SKFIITNPIUXzf0FRZl6JRppGtLGOmY6hjpGOKQjHamr@BwA "Python 3.8 – Try It Online")**
[Answer]
# [J](http://jsoftware.com/), 9 bytes
```
1#.2&|*<:
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DZX1jNRqtGys/mtypSZn5CsYKdimKZjpKBjqKJjogBjGEHETkLixjoIRGBmCSaiUoYGCrQJY0gwmYwoh/wMA "J – Try It Online")
* `1#.` Sum of applying the following to each element...
* `2&|` Remainder when divided by 2
* `*` Times...
* `<:` Number decremented by 1
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-mx`](https://codegolf.meta.stackexchange.com/a/14339/), 3 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
³&6
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW14&code=syY2&input=WzMsIDYsIDEsIDIsIDUsIDIsIDVd)
Saved 2 bytes using [Arnauld's formula](https://codegolf.stackexchange.com/a/200429/58974) so be sure to `+1` him if you're `+1`ing this.
## Original, 5 bytes
```
fu xÉ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ZnUgeMk&input=WzMsIDYsIDEsIDIsIDUsIDIsIDVd)
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), 29 28 26 bytes
```
/3|5/{x+=$0-1}END{print+x}
```
[Try it online!](https://tio.run/##SyzP/v9f37jGVL@6QttWxUDXsNbVz6W6oCgzr0S7ovb/f2MuMy5DLiMuUxAGAA "AWK – Try It Online")
*-1 byte thanks to Jo King*
*-2 bytes thanks to user41805*
`+x` is needed so that inputs with no odd numbers still return 0.
[Answer]
# [PHP](https://php.net/), ~~55~~ ~~53~~ 51 bytes
```
fn($a)=>array_sum(array_map(fn($v)=>$v%2*~-$v,$a));
```
[Try it online!](https://tio.run/##K8go@G9jX5BRwMWlkmb7Py1PQyVR09YusagosTK@uDRXA8LKTSzQAMmVAeVUylSNtOp0Vcp0gEo1rf@nJmfkK6ikaUQb65jGAvkA "PHP – Try It Online")
-2 bytes thanks to @RGS
[Answer]
# [Haskell](https://www.haskell.org/), 23 bytes
```
f x=sum[n-1|n<-x,odd n]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P02hwra4NDc6T9ewJs9Gt0InPyVFIS/2f25iZp5tQVFmXolKbmKBQppCdLSxjoIpGBnF6kSb6SgY6iiY6CgAGcZAPlDSCIwMwSRUyAzGN4WQsbH/AQ "Haskell – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~40~~ ~~33~~ 32 bytes
Saved 7 bytes thanks to [RGS](https://codegolf.stackexchange.com/users/75323/rgs)!!! 
```
lambda d:sum(i%2*~-i for i in d)
```
[Try it online!](https://tio.run/##XZNBa4QwEIXv/opBKGhxoU5iWBbssb@gt@0ebI1U2HUXzUKL2L9ujSHpqxfJ8yVvvhnN7dt8XjsxN@XbfK4u73VF9WG4X5L2gR9/di01155aajuq09nowQxlEiXHPKP8lNFTmjnBKMQi2AuJTrEI6YUKDmMaYxpjGmMaYxpjmnBp7AWjEOGMcGnBsWnKCxUciWwS2SSySWSTyCaRrXBp0gtGIQJB4dKCY9P2XqjgKGRTyKaQTSGbQjaFbGo7RJyJbQlxbfPo2y@NZYqwfx/GiLRi3Z/j/MSm3naKvDn/VyIPDTiMf92L9SSvHm9@AOXfFu7ps9KoL8fX/q4PcTXEGb1U52FZd1dDi54ieylMpu21WO/EIaJb33YmaeLRTLR7prFJTDrR2B/toiz1aSL9ddMfRtdxOv8C "Python 3 – Try It Online")
This turns out to be a total rip off of [Jonathan Allan](https://codegolf.stackexchange.com/users/53748/jonathan-allan)'s Python answer so update him instead.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 25 bytes
```
Tr[(Mod[#,2]#//.0->1)-1]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n277P6QoWsM3PyVaWccoVllfX89A185QU9cwVu1/QFFmXomCQ7pDtbGOgpmOgqGOgpGOgimErP3/HwA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 20 bytes
```
a=>a.Sum(x=>x--%2*x)
```
[Try it online!](https://tio.run/##ldQxa8MwEIbhPb/CS8EuccAn3S2JvRQ6ZevQORgHBK0CsUMNpb/dxQnt/N5y0ydxPEhfP9b9mJbXW@4PxzROh5Snblusszi3y6ntTru322c5t91c10/yPFfLfrN5ueTx8jHs3q9pGo4pD@W5zMNX8X/Fd7Mtmp@q2rOo8Gjg0cijyqMGo8IFhAsIFxAuIFxAuEDgAoELBC4QuEDgAoELRC4QuUDkApELRC4QuYByAeUCygWUCygXUC5gXMC4gHEB4wLGBczXA67Hpb6/4Krv6HsPrk0aV@H5yiG4BH2fWVx7@1jszrI2hqu35bHVfTqO2d8Zfcz15PIL "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~50~~ 48 bytes
Saved 2 bytes thanks to [xibu](https://codegolf.stackexchange.com/users/90181/xibu)!!! 
```
s;f(l,p)int*p;{for(s=0;l--;)s+=*p%2*~-*p++;l=s;}
```
[Try it online!](https://tio.run/##Xc/dCoIwFAfw@57iEATbPCPdh10MexHrIgwjMBu5O7FXt@XSWjDG4H/O75xV/FJV49iZmjRo6bV1zJq@vj9IV6Sm4dzQLimY3Qj25MwmiWmKzgzj7XRtCe1XvgFcVspj0SsEgZANBrYMUmDblX34uCbrTwJ8D5vzoV0j1ESiyyg1ARCl8oBE0NMRwcgi5JtGjkInFkeWuXdyPwvBD/UPGSjxK0V5hGl0csHUhMlpdzG1iMVTf5tFJRGZo1MLqctdIPO5WId7/nCs/ldF8A6dfsPD@AI "C (gcc) – Try It Online")
Inputs an integer array pointer preceded by its length.
[Answer]
# [Java (JDK)](http://jdk.java.net/), ~~47~~ 45 bytes
```
r->{int s=0;for(int i:r)s+=i%2*~-i;return s;}
```
First time code golfing, hope I posted this right.
-2 Bytes by removing unneeded curly brackets
[Try it online!](https://tio.run/##VZDLTsMwEEXX7VdcRUKKyUMVEpua8Ad00yViMXHTyiV1KtspQpX59TB2KIjN3Hkce0b3SBeqjrv3SfXkHF5Im@sS0MZ3dk@qwyaWqQGVc3x9gxaSe2HJYQODZrLV8zUCrlnJ/WAjBr22whWNvnu4/6q0tJ0frYGTYZLx4Xlse63gPHmWy6B3OPHufOutNgdeQvbgxLz79iWhwUqCigJPDR6lSNOZ@aPamWr/U5Fb3BCVEJUIBngCbD@d7071MPr6zCf43uSEAlmZcWx/MxWzNTKwmu4jGZaL2tQqj@Vs0BVUoi0ZDoK9WoSfE2YNybwwfQM "Java (JDK) – Try It Online")
[Answer]
# TI-BASIC, ~~13~~ 12 bytes
I found some 12 byte solutions
```
Ans-1:sum(Ansnot(fPart(Ans/2
```
The previous is the same byte count as below due to the line separator costing a byte
```
sum((Ans-1)2fPart(Ans/2
```
The above solutions use NfPart(Ans/N as a modulus operation to judge even/odd, giving us a list of dice that can have petals. Multiplying that by the original list -1 restores the petal counts to the list which can then be summed
```
2sum(Ans=3)+4sum(Ans=5
```
The original 13 byte solution simply compared the list once against 3 and separately against 5 before summing those results independently to get the petal count
All the above solutions take input as a list in Ans
[Answer]
# [Brain-Flak](https://github.com/Flakheads/BrainHack), ~~66~~ ~~60~~ ~~44~~ 42 bytes
*Two bytes saved by [Jo King](https://codegolf.stackexchange.com/users/76162)*
```
({(({}[()])<>)<>{<({}[()])><>([{}])<>}{}})
```
[Try it online!](https://tio.run/##SypKzMzLSEzO/v9fo1pDo7o2WkMzVtPGDoiqbWBcOxs7jejqWpB4bXVtreb///9N/xv9NwaShgA "Brain-Flak (BrainHack) – Try It Online")
This challenge seems to ellude a straight forward solution in Brain-flak. It was quite fun to golf.
[Answer]
# [Julia 1.0](http://julialang.org/), ~~23~~ 16 bytes
```
l->sum(l.^3 .&6)
```
[Try it online!](https://tio.run/##XZLBaoUwEEX3fsWsioJ9NJNkeBtLP6I7sVDos1ishRqhf2@NIdPbuBBvbubmzJiPbZ5ezc8@dvt8/7hun/V8ebF0uZNmD7c1rF1d1b1pyQwtPTRtEozCHoKzcOj4Q7gsRB3GNMY0xjTGNMY0xjSb0jgLRmG1xqY0dWKaZCHqOGRzyOaQzSGbQzaHbD6luSwYhVUCn9LUiWnXLEQdQTZBNkE2QTZBNkE2KYeIM4ktIW5sHv34p/EYr/uvOkakted@g/OzxXnlFLmo/zvCaAMJ41/39qzk0@PiAkhe9emds5pqW6flnZ6PC1@NX98UaFrovP4VHc9T/KSxDr0ZGuo6Cj0P1W15238B "Julia 1.0 – Try It Online")
-7 Bytes thanks to [Maria Miller](https://codegolf.stackexchange.com/users/92689/maria-miller)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~5~~ 4 bytes
```
ÉÏ<O
```
[Try it online!](https://tio.run/##yy9OTMpM/f//cOfhfhv///@jjXUUzHQUDHUUjHQUTCFkLAA)
*-7 byes thanks to Expired Data*
*-1 byte thanks to Grimmy*
As promised, someone who knows 05AB1E better than I came and golfed it somehow.
## 11 bytes
```
ε2%}Iε1-}*O
```
[Try it online!](https://tio.run/##yy9OTMpM/f//3FYj1VrPc1sNdWu1/P//jzbWUTDTUTDUUTDSUTCFkLEA "05AB1E – Try It Online")
I'm sure someone who knows 05AB1E better than I do will come along and golf this somehow. Really simple:
```
ε2%}   # Map the code 2% (mod 2) to each element of the implicit input
Iε1-}  # Map the code 1- (sub 1) to each element of the explicit input
*O     # Multiply the two lists and sum
```
[Answer]
# [Perl 5](https://www.perl.org/) `-pl`, 15 bytes
```
$\+=$_%2*$_&6}{
```
[Try it online!](https://tio.run/##K0gtyjH9/18lRttWJV7VSEslXs2stvr/f2MuMy5DLiMuUxD@l19QkpmfV/xftyAHAA "Perl 5 – Try It Online")
Takes the input list as one entry per line.
[Answer]
## [Roj](https://github.com/RojerGS/Roj), ~~134~~ ~~92~~ ~~88~~ ~~86~~ 65 bytes
Considerably easier than the previous challenge. Takes numbers in separate lines and end input with the input `0`. Outputs via return value. (Dramatically saved 42 bytes by using dynamic input)
```
O=0;i=1;while i do readint i;if i==3 or i==5 do O=O+i-1 end end;O
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 8 bytesSBCS
```
+/⊢|¯2|⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///X1v/UdeimkPrjWqA9P@0R20THvX2Peqb6un/qKv50HrjR20TgbzgIGcgGeLhGfw/TcFQwVjBVMEEiI250hTMFIzA0FjBBAA "APL (Dyalog Unicode) – Try It Online")
A port of [xnor's double modulo trick](https://codegolf.stackexchange.com/a/200407/78410).
### How it works
```
+/⊢|¯2|⊢
    ¯2|⊢  ⍝ Input modulo -2; 0 if even, -1 if odd
  ⊢|      ⍝ That modulo input; 0 if even, n-1 if odd
+/        ⍝ Sum
```
---
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 9 bytesSBCS
```
2∘|+.×-∘1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///3@hRx4wabb3D03WBDMP/aY/aJjzq7XvUN9XT/1FX86H1xo/aJgJ5wUHOQDLEwzP4f5qCsYIxV5qCoYKRgomCGZBlCmSZAtnGAA "APL (Dyalog Unicode) – Try It Online")
### How it works
```
2∘|+.×-∘1
      -∘1  ⍝ Decrement input
   +.×     ⍝ Dot product with
2∘|        ⍝ Input modulo 2
```
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 13 bytes
```
{+/(2!x)*x-1}
```
[Try it online!](https://tio.run/##Lc87DoMwEEXRrThVIBGKPL8i7IeGghYJZe2OLjPNK3zm53059jG27/X@TPI459e59N/YnlNvfW29CaGEEU7E2gQVVFBBBRVUUUUVVVRRRQ011FBDDTXUUUcdddRRRwMNNNBAA43am3O8pue9VjPysedxdYVmQ@2XtKqNuzfyCwLmb/UWoaj5PP4 "K (oK) – Try It Online")
Essentially same as [Jonah's J solution](https://codegolf.stackexchange.com/a/200395/75681)
[Answer]
# [W](https://github.com/A-ee/w), 5 [bytes](https://github.com/A-ee/w/wiki/Code-Page)
```
►S≡5u
```
Uncompressed:
```
(S2m*J
(      % Decrement input
 S     % Swap a copy of the input up
  2m   % Modulo the value by 2
    *  % Multiply them
     J % Find their sum
```
```
[Answer]
# [Icon](https://github.com/gtownsend/icon), 50 bytes
```
procedure f(a)
n:=0&n+:=!a-1=(2|4)&\z
return n
end
```
[Try it online!](https://tio.run/##y0zOz/v/v6AoPzk1pbQoVSFNI1GTK8/K1kAtT9vKVjFR19BWw6jGRFMtpoqrKLWktChPIY8rNS8FSUtuYmaehiaXAhCUF2WWpGqkaUQb6iiYxmpiCppgCBoDVYKREYaUmY4CSIuOApBhjE0jRIERRDvURpDbAA "Icon – Try It Online")
## Explanation:
```
procedure f(a)         # the argument a is the list 
    n:=0 &             # sets the sum to 0 and  
    n+:=!a-1=(2|4) &   # add to n (n+:=) each element of a decreased by one (!a-1),
                       # if it now equals 2 or 4 (=(2|4)) and
    \z                 # loop (in fact checks if a variable z exists - since it 
                       # doesn't, backtracks to get the next element of a, if any)
    return n           # returns the sum
end
```
[Answer]
# [Actually](https://github.com/Mego/Seriously), 8 bytes
A port using Arnauld's formula.
```
⌠3ⁿ6&⌡MΣ
```
[Try it online!](https://tio.run/##S0wuKU3Myan8//9RzwLjR437zdQe9Sz0Pbf4//9oQx0jHeNYAA "Actually – Try It Online")
[Answer]
# Excel, 34 bytes
```
=SUMIF(A:A,3)/3*2+SUMIF(A:A,5)/5*4
```
`SUMIF` does much of the work for us.
Feel like there should be a solution using `SUMPRODUCT`, but have not found it yet.
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 12 bytes
```
psf{2.%}?d++
```
[Try it online!](https://tio.run/##VZG7DoJAEEV7v4KQGAvByOzshGQT/AMbS7UxYizQ@AiV4dvRmcUrNuTmsmfODhzaR1M/723dN9fLa5aFsNumeZWGkO/72/P0osW0Wx3n835z7tp1X2RJkeRVspx8EiE5TaSJ0XlNrEliR2AJLIElsASWwLqBJU2E5OI5N7DWGSuaJHYML8PL8DK8DC/D6weWNRGSiw4/sNYZW2qS2Am8Aq/AK/AKvPK3L1bRi8GuN8cb/eCY43/HSlsafmfHCizsxqP/1qYxMxpY2DWj7reDM4DsBY3/hnwrH59xxBs "Burlesque – Try It Online")
```
ps     # Parse input to array
f{2.%} # Filter for mod2 == 1
?d     # Decrement each
++     # Sum
```
]