Please help me with the task: Sum of squares calculator

Hello, I’m working on this task:

Write a program that reads two integer numbers from the screen, min and max, and outputs the sum of all squares of integers between min(including) and max(not including). If min is bigger than max, the program should output “min should be smaller than max!”
Example 1:
>4
>9
190
(190 = 4*4 + 5*5 + 6*6 + 7*7 + 8*8)

Example 2:
>14
>3
min should be smaller than max!

Here is my code:


namespace ForLoops
{
   class SumOfSquares
   {
       static void Main(string[] args)
       {
           int min = int.Parse(Console.ReadLine());
           int max = int.Parse(Console.ReadLine());
           int sum = 0;
           if (min < max)
           {
               {
               for (int i = min; i < max; i++)
               sum = sum + (i * i);
               }
               Console.WriteLine(sum);
           }
           else
           {
               Console.WriteLine($" {min} should be smaller than {max} ");
           }
       }
   }
}


Can anyone please help me to solve it?

“min should be smaller than max!” - is the exact output you should expect in case min is bigger. In your case you output " 15 should be smaller than 7 " - it’s wrong.

Thank you very much!)