about summary refs log tree commit diff
path: root/others/volume1/004.pas
blob: e619f50fe8ce1f883a28b68ade5d2b26b9699735 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uses clib;

var
  prime: array [2..1000000] of boolean;
  i, j, n, k: longint;

begin
  for i := 2 to 1000000 do
    prime[i] := true;
  for i := 2 to 1000 do
    if prime[i] then
      for j := i to 1000000 div i do
        prime[i * j] := false;

  readln(n, k);
  writeln(isprime(n));
  for i := 2 to k do
    if prime[i] then
      write(i, ' ');
  writeln
end.