If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.

 The sum of these multiples is 23.

 Find the sum of all the multiples of 3 or 5 below 1000.  

            long result = 0;
for (int i = 0; i < 1000; i++)
{
if (i%3 == 0 || i%5 == 0) result += i;
}
Console.WriteLine(result);

相关文章:

  • 2021-09-12
  • 2022-02-15
  • 2021-08-14
  • 2022-01-02
  • 2021-04-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-11
  • 2022-01-29
  • 2022-02-14
  • 2021-10-03
  • 2021-08-08
  • 2021-06-14
  • 2022-03-03
相关资源
相似解决方案