free pascal用 while 语句计算1—1000之间能同时被3和5整除的整数的和

速度啊
2024-12-11 15:31:21
推荐回答(1个)
回答1:

program calc;

var
total: dword;
i: integer;

begin
total := 0;

for i:=1 to 1000 do
if((i mod 15) = 0)then
total += i;

writeln('Total: ', total);
end.