Please help me with the task: Save the Earth.

Hello, I’m working on this task:

Read an integer number from the screen and store it in a short variable named count. Write a program that prints numbers from 1(including) to count (including), each on a new line. But for multiples of two, print ‘Save’ instead of the number, and for the multiples of three print ‘Earth’. For numbers which are multiples of both two and three, print ‘SaveEarth’.
Example:
>7
1
Save
Earth
Save
5
SaveEarth
7

Here is my code:


namespace PrimitiveTypes
{
   class SaveEarth
   {
       static void Main(string[] args)
       {
          short count = short.Parse(Console.ReadLine());

           for (int i = 1; i <= count; i++)
           {
               if (i % 2 == 0 && i % 3 == 0)
                   Console.WriteLine("saveEarth");
               else if (i % 3 == 0)
                   Console.WriteLine("Earth");
               else if (i % 2 == 0)
                   Console.WriteLine("save");
               else
                   Console.WriteLine(i);                
           }

           
       }
   }
}

Can anyone please help me to solve it?

The problem can be in spelling. Keep attention to capital/lower case:
saveEarth → SaveEarts

1 Like

Problem solved. Thanks.

1 Like