find the sum of the multiples of 3 and 5 below 1000

前端 未结 12 960
我在风中等你
我在风中等你 2021-01-18 08:04

Ok guys, so I\'m doing the Project Euler challenges and I can\'t believe I\'m stuck on the first challenge. I really can\'t see why I\'m getting the wrong answer despite my

12条回答
  •  别那么骄傲
    2021-01-18 08:37

        int count = 0;
    for (int i = 1; i <= 1000 / 3; i++)
    {
    count = count + (i * 3);
    if (i < 1000 / 5 && !(i % 3 == 0))
    {
    count = count + (i * 5);
    }
    }
    

提交回复
热议问题