Advertisement
STANAANDREY

factprim2

Nov 15th, 2018 (edited)
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     unsigned long x, y, f, p, i, n;
  8.     cout << "n=";
  9.     cin >> n;
  10.     i = 1;
  11.     while (i <= n)
  12.     {
  13.         cin >> x;
  14.         y = x;
  15.         f = 2;
  16.         while (x > 1)
  17.         {
  18.             p = 0;
  19.             while (x % f == 0)
  20.             {
  21.                 x /= f;
  22.                 p++;
  23.             }
  24.             if (p != 0) cout << "factoru " << f << " la puterea " << p << endl;
  25.             f++;
  26.         }
  27.         ++i;
  28.     }
  29.     return 0;
  30. }
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement