snt123
unknown
c_cpp
2 years ago
475 B
10
Indexable
#include <iostream>
#include <math.h>
using namespace std;
bool snt(int n)
{
if(n < 2)
{
return 0;
}
for(int i = 2 ; i <= sqrt(n); i++)
{
if(n % i == 0)
{
return 0;
}
}
return 1;
}
int main()
{
int n;
cin >> n;
if(snt(n))
{
cout << n << " la so nguyen to";
}
else
{
cout << n << " khong la so nguyen to";
}
return 0;
}
Editor is loading...
Leave a Comment