Цитата:
Сообщение от konstantin.shef
Pascal ABC
|
Ну, тогда-то что...
Код:
VAR
i,A,S:Integer;
q:Boolean;
Function Test(J:Integer):Boolean;
Var
m:Integer;
b:Boolean;
begin
m:=(J div 2)+1;
b:=true;
Repeat
Dec(m);
If (J mod m)=0 then b:=false;
Until (b=false) or (m=2);
Test:=b;
end;
Begin
i:=0;
S:=0;
Writeln('Numbers:');
Repeat
q:=false;
Inc(i);
Write('Next number ');
If (i<4) or ((i>=4) and (Test(i))) then q:=true;
If q then write('(prime position ',i,') ');
Readln(A);
If (A>0) and q then Inc(S,A);
Until A=0;
Writeln;
Writeln('Sum= ',S);
Readln
End.