Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int ktsonguyento(int &n)
- {
- int dem = 0;
- cout << "nhap so duong kiem tra = ";
- cin >> n;
- if (n < 2)
- {
- cout << "dieu kien khong hop le";
- }
- for (int i = 2; i <= sqrt(n); i++)
- {
- if (n%i == 0)
- {
- dem++;
- }
- }
- if (dem == 0)
- return true;
- else
- return false;
- }
- void main()
- {
- int n;
- if (ktsonguyento(n) == true)
- cout << n << " la so nguyen to";
- else
- cout << n << "khong phai la so nguyen to";
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement