(I am being honest, it is an assignment that I have attempted)

I have a question/assignment that requires me to do a for loop that counts to a specific number (i am using 25) and skips every number that is (for example) divisible by 3.

I have tried this:

int o;
      for (o = 1; o <= 25; o++)
          {
              if (o % 3)
              continue;
              Console.WriteLine(o);
          }

My solution didn't work, nor did google help me out that much... I know the answer is super simple and I am just missing it somehow because I am tired.

Thanks in advance.

Recommended Answers

try

int o;
for (o = 1; o <= 25; o++)
{
    if (o % 3 != 0)
        Console.WriteLine(o);
}
Console.ReadLine();
Jump to Post

All 2 Replies

try

int o;
for (o = 1; o <= 25; o++)
{
    if (o % 3 != 0)
        Console.WriteLine(o);
}
Console.ReadLine();
commented: Thanks! +7

Thanks tinstaafl!

It worked perfectly, I didn't realize I was missing !=0 in line 4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.