Skip to main content
2 of 2
deleted 15 characters in body
S.S. Anne
  • 3.4k
  • 11
  • 31

C (gcc), 38 bytes

b;f(int*a){b=(b=*a++)?b%2*~-b+f(a):0;} 

Input as 0-terminated array a.

Recursive function.

-10 bytes thanks to Arnauld!

Try it online!

S.S. Anne
  • 3.4k
  • 11
  • 31