procedure isprime(n: longint; var ip: boolean);
var i, sqrtn: longint;
begin
if (n >= 5) and ((n - 1) mod 6 = 0) or ((n + 1) mod 6 = 0)
then begin
i := 5;
sqrtn := trunc(sqrt(n));
ip := false;
while i <= sqrtn do
begin
if n mod i = 0 then exit;
inc(i, 2)
end;
ip := true
end
else ip := (n = 2) or (n = 3)
end;
var n, m: longint;
mp: boolean;
begin
m := 3;
write('n = ');
readln(n);
if n <= m
then writeln('Prime Mersenne numbers, smaller this number, don''t exist.')
else begin
writeln('Prime Mersenne numbers, there is less than this number:');
while n > m do
begin
isprime(m, mp);
if mp then writeln(m);
m := m * 2 + 1
end
end;
readln
end.
var i, sqrtn: longint;
begin
if (n >= 5) and ((n - 1) mod 6 = 0) or ((n + 1) mod 6 = 0)
then begin
i := 5;
sqrtn := trunc(sqrt(n));
ip := false;
while i <= sqrtn do
begin
if n mod i = 0 then exit;
inc(i, 2)
end;
ip := true
end
else ip := (n = 2) or (n = 3)
end;
var n, m: longint;
mp: boolean;
begin
m := 3;
write('n = ');
readln(n);
if n <= m
then writeln('Prime Mersenne numbers, smaller this number, don''t exist.')
else begin
writeln('Prime Mersenne numbers, there is less than this number:');
while n > m do
begin
isprime(m, mp);
if mp then writeln(m);
m := m * 2 + 1
end
end;
readln
end.