jae-l
1/2/2017 - 10:34 PM

For loop that calculates the sum of all odd integers in the range [1…n], which are not divisible by 7.

For loop that calculates the sum of all odd integers in the range [1…n], which are not divisible by 7.

int n = int.Parse( Console.ReadLine());
int sum = 0;
		
for (int i = 1; i <= n; i += 2)
{
  if (i % 7 == 0)
  {
    continue;
  }
  sum += i;
}

Console.WriteLine( "sum = " + sum);

//  10
//  sum = 18