Chap4ev

разложение на простые множители

Oct 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.     cin >> n;
  8.     for(int i = 2; i<=n; i++)
  9.         if (n%i == 0){
  10.             int j = 0;
  11.             for (;n%i ==0;j++)
  12.                 n = n/i;
  13.             cout << i << ( (j != 1)? ("^" + to_string(j)) :"" ) << " ";
  14.         }
  15.     return 0;
  16. }
Add Comment
Please, Sign In to add comment