0% found this document useful (0 votes)
16 views2 pages

Atestat 11

The document contains C++ code to check if a number is prime and output all pairs of prime numbers multiplied within a given range. The code uses a function to check primality and loops through numbers to find primes and output their pairs.

Uploaded by

Maloș Mihai.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Atestat 11

The document contains C++ code to check if a number is prime and output all pairs of prime numbers multiplied within a given range. The code uses a function to check primality and loops through numbers to find primes and output their pairs.

Uploaded by

Maloș Mihai.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

using namespace std;

int prim(int x)

int ok=1;

for (int d=2; d<=x/2; d++)

if(x%d==0)

ok=0;

break;

if(ok==0)

return 0;

else return 1;

int main()

int N, k=0,v[100];

cout<<"N:"; cin>>N;

for (int i=2; i<=N;i++)


{

if (prim(i)==1)

k++;

v[k]=i;

for (int i=1; i<=k; i++)

for (int j=i; j<=k; j++)

cout<<v[i]*v[j]<<" ";

return 0;

You might also like