Project Euler Problem 1 in C#. Basic use of the for loop, if statement, and the Console.WriteLine function. using System; namespace Problem1 { class MainClass { public static void Main (string[] args) { int i; int total=0; for (i=1;i<1000;i++){ if (i%5==0 || i%3==0) total+=i; } Console.WriteLine("The result is {0}",total); } } }
No comments:
Post a Comment