Pascal:
var n, i: integer;
begin
for n := 1 to 1000 do
if (n mod 17 = 0) and (n mod 10 = 3) then
i := i + n;
writeln(i);
end.
Python:
n, i = 0, 0
for n in range(1,1001):
if n % 17 == 0 and n % 10 == 3:
i += n
print(i)
Результат: 2465
def fun(x):
count = (x-153)//170 + 1
sum_ = count * (5*count + 4)
return 17*sum_
print(fun(1000))
Pascal:
var n, i: integer;
begin
for n := 1 to 1000 do
if (n mod 17 = 0) and (n mod 10 = 3) then
i := i + n;
writeln(i);
end.
Python:
n, i = 0, 0
for n in range(1,1001):
if n % 17 == 0 and n % 10 == 3:
i += n
print(i)
Результат: 2465
def fun(x):
count = (x-153)//170 + 1
sum_ = count * (5*count + 4)
return 17*sum_
print(fun(1000))