Guest User

Untitled

a guest
Jan 7th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6. double n;
  7. int suma=0;
  8.  
  9. int main()
  10. {
  11.    cout<<"podaj n"<<endl;
  12.    cin >>n;
  13.     //sprawdzam kazda liczbe od 1 do n
  14.    for(int j=1;j<=n;j++){
  15.     //sprawdzam kazdy dzielnik od 2 do n
  16.    for(int i=2;i<=n;i++){
  17.         //czy j dzieli sie przez i
  18.         if(j%i== 0){
  19.  
  20.             double z=sqrt(i);
  21.             if ((double)((int)z) == z){
  22.                suma++;
  23.                break;
  24.             }
  25.  
  26.         }
  27.  
  28.    }
  29.    }
  30. cout<<"Ilosc bezkwadratowych liczb <="<<n<<" to: "<<n-suma-1;
  31.     return 0;
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment