Advertisement
EWTD

prime numbers till n

Sep 16th, 2017
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.36 KB | None | 0 0
  1. program lolkek;
  2.  
  3. var
  4.   a, i, b: integer;
  5.   ans:boolean;
  6.  
  7. function pr(a: integer): boolean;
  8. var
  9.   i: integer;
  10.   ans: boolean;
  11. begin
  12.   ans := False;
  13.   for i := 2 to (a - 1) do
  14.   begin
  15.     if (a mod i) = 0 then
  16.       ans := True;
  17.   end;
  18.   result := ans;
  19. end;
  20.  
  21. begin
  22.   for i:= 1 to 500 do
  23.   begin
  24.   if not(pr(i,b,ans)) then
  25.   writeln(i);
  26.   end;
  27. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement