Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Prost(inpt: integer): boolean;
- var
- i: integer;
- begin
- Prost := true; //initially res of fuck is 1
- if inpt < 2 then //there arent prime nums that are less then 2
- Prost := false //so if input val is less than 2 then res of fuct is 0
- else
- for i := 2 to inpt div 2 do //iterante over nums from 2 to half of the input val
- if ((inpt mod i) = 0) then //if there isnt any remaind of division input num on present num from iteration
- Prost := false; //then res of func is 0
- end;
- function CheckAvailProst(a,b:integer):string;
- var res:string;
- i:integer;
- begin
- CheckAvailProst:=''; //firstly the string is empty
- for i:=a to b do //iterate numbers in range from minimalm inputed to maximum
- if Prost(i) then //if present num in range is prime then
- res:=res+i+' '; //add to the string present value and space
- CheckAvailProst:=res;
- end;
- var
- i,a,b: integer;
- begin
- read(a,b); //read borders of range
- if CheckAvailProst(a,b)<>'' then //if every num in range of theese nums if prime then
- writeln(CheckAvailProst(a,b)) //write result of fucnt that include string
- else
- if CheckAvailProst(a,b)='' then //if there arent any symbols in the string then
- writeln('0'); //write 0
- end.
Add Comment
Please, Sign In to add comment