Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- char numero=0;
- cout<<"Inserisci un numero: ";
- cin>>numero;
- int N;
- int contaPassi;
- int Resto;
- int K;
- K = 1;
- contaPassi = 0;
- cout << "Inserisci un numero intero per verificare se รจ primo" << endl;
- cin >> N;
- while(K <= N){
- Resto = N % K;
- if(Resto == 0){
- contaPassi = contaPassi + 1;
- }
- K = K+1;
- }
- if(contaPassi == 2){
- cout << "Il numero " << N << " e' primo" <<endl;
- }
- else {
- cout << "Il numero " << N << " non e' primo" <<endl;
- }
- system ("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement