title: ParallelFor code for finding sum of few elements in an array (Subsetsum problem)
body: <p>I have the following C# code fragment:</p>
  
  <pre><code>using System;
  
  class count {
   public static void Main()
   {
    int [] a = {-30, 30, -20, -10, 40, 0, 10, 5};
    int i,j,k;
    int N=8;
  
    for (i=0; i &lt; N; ++i)
     for (j=i+1; j &lt; N; ++j)
      for (k=j+1; k &lt; N; ++k)
       if (a[i] + a[j] + a[k] == 30)
        Console.WriteLine (a[i].ToString () + a[j].ToString() + a[k].ToString());
  
   }
  }
  </code></pre>
  
  <p>What the above program does is, find out the triplets a1, a2, a3 from an Array A, such that the sum of the triplets is 30. </p>
  
  <p>I want to know how I can do the sum calculation using the C# Parallel.For extension. </p>
  
  <p>I know that this is used as an interview question and there are better alternative algorithms than an i,j,k loop. However, all I want is just to understand how to perform this using Parallel extensions for C# , in an effective way. </p>