Advertisement
Abelsor

S3_Ejercicio_7

Feb 23rd, 2023 (edited)
971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.    
  5.     float nf;
  6.     int n;
  7.    
  8.     do{
  9.         cin>>nf;
  10.     }
  11.     while(nf<=2 or nf!=int(nf));
  12.    
  13.     n = int(nf);
  14.    
  15.     for(int i=1 ; i<=n ; i++){
  16.         int cont = 0;
  17.         for(int j=1 ; j<=i ; j++){
  18.             if(i%j==0){
  19.                 cont++;
  20.             }
  21.         }
  22.         if(cont == 2)
  23.             cout<<i<<" ";
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement