Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created May 23, 2022 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgolubyev/b6b5556c7b19d29fa03bea86724766ac to your computer and use it in GitHub Desktop.
Save lgolubyev/b6b5556c7b19d29fa03bea86724766ac to your computer and use it in GitHub Desktop.
private static int SumOdd_BranchFree_Parallel(int[] array)
{
int counterA = 0;
int counterB = 0;
for (int i = 0; i < array.Length; i += 2)
{
var elementA = array[i];
var elementB = array[i + 1];
var oddA = elementA & 1;
var oddB = elementB & 1;
counter += (oddA * elementA);
counter += (oddB * elementB);
}
return counterA + counterB;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment