Advertisement
avr39ripe

cppDivBySquareNotDivByCube

Mar 15th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     int num{ 0 };
  6.  
  7.     std::cout << "Enter number\n";
  8.     std::cin >> num;
  9.  
  10.     for (int divisor{ 1 }, divSquare; divSquare = divisor * divisor, divSquare < num; ++divisor)
  11.     {
  12.         if (num % divSquare == 0 and num % (divSquare*divisor) != 0)
  13.         {
  14.             std::cout << divisor << ' ';
  15.         }
  16.     }
  17.     std::cout << '\n';
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement