var
i, si, N, ss: Integer;
s: string;
begin
Write ('Введите N: ');
ReadLn (N);
s := IntToStr (N);
ss := 0;
for i := 1 to Length (s) do begin
si := StrToInt (s [i]);
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
// второй вариант решения
var
si, N, ss: Integer;
begin
Write ('Введите N: ');
ReadLn (N);
ss := 0;
while N > 0 do begin
si := N mod 10;
N := N div 10;
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
var
i, si, N, ss: Integer;
s: string;
begin
Write ('Введите N: ');
ReadLn (N);
s := IntToStr (N);
ss := 0;
for i := 1 to Length (s) do begin
si := StrToInt (s [i]);
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
// второй вариант решения
var
si, N, ss: Integer;
begin
Write ('Введите N: ');
ReadLn (N);
ss := 0;
while N > 0 do begin
si := N mod 10;
N := N div 10;
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
738:2=369 R=0 0
369:2=184 R=1 10
184:2=92 R=0 010
92:2=46 R=0 0010
46:2=23 R=0 00010
23:2=11 R=1 100010
11:2=5 R=1 1100010
5:2=2 R=1 11100010
2:2=1 R=0 011100010
1:2=0 R=1 1011100010
(738)₁₀=(1011100010)₂
2 - шестнадцатеричная
738:16=46 R=2 2
46:16=2 R=14 E2
2:16=0 R=2 2E2
(738)₁₀=(2E2)₁₆