Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- double n;
- int suma=0;
- int main()
- {
- cout<<"podaj n"<<endl;
- cin >>n;
- //sprawdzam kazda liczbe od 1 do n
- for(int j=1;j<=n;j++){
- //sprawdzam kazdy dzielnik od 2 do n
- for(int i=2;i<=n;i++){
- //czy j dzieli sie przez i
- if(j%i== 0){
- double z=sqrt(i);
- if ((double)((int)z) == z){
- suma++;
- break;
- }
- }
- }
- }
- cout<<"Ilosc bezkwadratowych liczb <="<<n<<" to: "<<n-suma-1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment