I just started the project Euler and I already have some problems. why do these methods produce different results?
int sum=0;
for (int i=0;i<n;i++)
{
if(i%3==0 || i%5==0)
sum+=i;
}
vs
int sum=0;
for (int i=0;i<n;i++)
{
if(i%3==0)
sum+=i;
if (i%5==0)
sum+=i;
}
Aucun commentaire:
Enregistrer un commentaire