Guest User

Untitled

a guest
Dec 14th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. function Prost(inpt: integer): boolean;
  2. var
  3. i: integer;
  4. begin
  5. Prost := true; //initially res of fuck is 1
  6. if inpt < 2 then //there arent prime nums that are less then 2
  7. Prost := false //so if input val is less than 2 then res of fuct is 0
  8. else
  9. for i := 2 to inpt div 2 do //iterante over nums from 2 to half of the input val
  10. if ((inpt mod i) = 0) then //if there isnt any remaind of division input num on present num from iteration
  11. Prost := false; //then res of func is 0
  12. end;
  13. function CheckAvailProst(a,b:integer):string;
  14. var res:string;
  15. i:integer;
  16. begin
  17. CheckAvailProst:=''; //firstly the string is empty
  18. for i:=a to b do //iterate numbers in range from minimalm inputed to maximum
  19. if Prost(i) then //if present num in range is prime then
  20. res:=res+i+' '; //add to the string present value and space
  21. CheckAvailProst:=res;
  22. end;
  23. var
  24. i,a,b: integer;
  25. begin
  26. read(a,b); //read borders of range
  27. if CheckAvailProst(a,b)<>'' then //if every num in range of theese nums if prime then
  28. writeln(CheckAvailProst(a,b)) //write result of fucnt that include string
  29. else
  30. if CheckAvailProst(a,b)='' then //if there arent any symbols in the string then
  31. writeln('0'); //write 0
  32. end.
Add Comment
Please, Sign In to add comment