View Single Post
Old 13-08-2009, 21:13   #8
punky
Inactive
 
Join Date: Jun 2003
Age: 44
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Programming Challenges?

I did more or less the same. Just one suggestion i'd make regarding your code Damien:

Spoiler: 
I'd use else ifs instead of ifs otherwise you'd get unnecessary repitition.

for (Int32 i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
Console.WriteLine(i + " is a multiple of both 3 AND 5!");
else if (i % 3 == 0)
Console.WriteLine(i + " is a multiple of 3");
else if (i % 5 == 0)
Console.WriteLine(i + " is a multiple of 5");

}

i.e you get:

12 is a multiple of 3
15 is a multiple of both 3 AND 5!
18 is a multiple of 3

instead of this:

12 is a multiple of 3
15 is a multiple of both 3 AND 5!
15 is a multiple of 3
15 is a multiple of 5
18 is a multiple of 3
punky is offline   Reply With Quote