Function IsPrime(n: Longint): Boolean; var i, sqrtn, delta: Word; begin if (n >= 5) and ((n - 1) mod 6 = 0) or ((n + 1) mod 6 = 0) then begin i := 5; delta := 2; sqrtn := Trunc(sqrt(n)); IsPrime := False; while i <= sqrtn do begin if n mod i = 0 then Exit; Inc(i, delta); delta := delta xor 6; {смена шага, то 2, то 4} end; IsPrime := True; end else IsPrime := (n = 2) or (n = 3); end; Var A,B,i : Integer; Begin Readln(A,B); For i:=A to B do If IsPrime(i) then Writeln(i); end.
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cstring>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>typedef unsigned long long ulol;
typedef long double ld;
typedef long long lol;
typedef long int li;#define mp make_pair
#define F first
#define S second
#define sqr(a) ( (a) * (a) )
#define pb push_back
#define INF 999999999
#define ret(a) cout << endl; system("pause"); return(a)
//#define ret(a) return(a)using namespace std;int main()
{
ld x;
cin >> x;
x = ( 8 / sqrt( x ) ) + sqrt(x);
cout << x;
ret(0);
}
var i, sqrtn, delta: Word;
begin
if (n >= 5) and ((n - 1) mod 6 = 0) or ((n + 1) mod 6 = 0) then begin
i := 5;
delta := 2;
sqrtn := Trunc(sqrt(n));
IsPrime := False;
while i <= sqrtn do begin
if n mod i = 0 then Exit;
Inc(i, delta);
delta := delta xor 6; {смена шага, то 2, то 4}
end;
IsPrime := True;
end else
IsPrime := (n = 2) or (n = 3);
end;
Var A,B,i : Integer;
Begin
Readln(A,B);
For i:=A to B do If IsPrime(i) then Writeln(i);
end.