23.1.23010270. Naći i Ispisati najmanji 10-cifreni prost broj.
Opis rješenja:
Listing programa:
/* 23010270 Naći i ispisati najmanji 10-cifreni prost broj */
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{ bool prost; long long kor;
cout << "najmanji 10-cifreni prost broj ";
for (long long x=100000000LL; x<1000000000LL; x++)
{prost=true;
kor=sqrt(x);
for (int i=2;i<=kor && prost==true;i++)
if (x%i==0) prost=false;
if (prost==true) {cout << " " << x ; break;}
}
system("PAUSE");
return EXIT_SUCCESS;
}
Ispis na ekranu:
Riješeni zadaci Index
|