velimir

Faktorizacija

Feb 26th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int i, j, x;
  8.     cin >> x;
  9.     for(i=2; i<=x; i++)
  10.     {
  11.         if(x%i==0)
  12.         {
  13.             for(j=0; x%i==0; j++)
  14.             {
  15.                 x/=i;
  16.             }
  17.             cout << "(" << i << "^" << j << ")";
  18.             if(x>1)cout << "*";
  19.     }
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment