jrliv
5/31/2017 - 5:41 PM

Example using nested for loops to print "lucky numbers" when (a + b) = (c + d). From Fundamentals of Computer Programming with C# http://www

Example using nested for loops to print "lucky numbers" when (a + b) = (c + d). From Fundamentals of Computer Programming with C# http://www.introprogramming.info/wp-content/uploads/2013/07/Books/CSharpEn/Fundamentals-of-Computer-Programming-with-CSharp-Nakov-eBook-v2013.pdf

for (int a = 1; a <= 3; a++)
{
  for (int b = 0; b <= 3; b++)
  {
    for (int c = 0; c <= 3; c++)
    {
      for (int d = 0; d <= 3; d++)
      {
        if ((a + b) == (c + d))
        {
          Console.WriteLine(" " + a + " " + b + " " + c + " " + d);
        }
      }
    }
  }
}