• May 10th 2005, 08:10 PM
Find the sum of all integers between 1 and 9999 that are divisible by 5 but not by 6 nor 7.

Any help is greatly appreciated!
• May 10th 2005, 10:04 PM
paultwang

Matlab code:
a = 0;
for i = 1:9999
if mod(i,5) == 0 && mod(i,6) ~= 0 && mod(i,7) ~= 0
a = a + i;
end
end
disp(a);
• May 18th 2005, 08:53 PM
Is there a way of not using a calculater to work this out, in a logic way, by not also writing all the numbers out.
• May 24th 2005, 07:57 PM
Quote:

Originally Posted by paultwang

Matlab code:
a = 0;
for i = 1:9999
if mod(i,5) == 0 && mod(i,6) ~= 0 && mod(i,7) ~= 0
a = a + i;
end
end
disp(a);

Is there a way of not using a calculater to work this out, in a logic way, by not also writing all the numbers out.
• May 25th 2005, 07:15 AM
paultwang
> 9999/5.;

1999.8

> 9999/30.;

333.3000000

> 9999/35.;

285.6857143

> 9999/210.;

47.61428571

> 1999*(1+1999)/2*5;
9995000

> 333*334/2*30;

1668330

> 285*286/2*35;

1426425

> 47*48/2*210;

236880

> 9995000-1668330-1426425+236880;

7137125

Thanks buggler@Undernet for the help on this method.
• May 28th 2005, 01:04 PM