Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool es_primo(int& numero) {
- int d=2;
- while (d*d<=numero) {
- if (numero%d==0) return false;
- else ++d;
- }
- return true;
- }
- int main () {
- int n;
- cin >> n;
- for (int i=1; i<=n; ++i) {
- int numero;
- cin >> numero;
- if (es_primo(numero)) cout << numero << " es primer" << endl;
- else cout << numero << " no es primer" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement