Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n, cp, ok = 0;
- int v[100000];
- cout << "n= "; cin >> n;
- cp = n;
- for(int i = 2; i <= cp / 2; i++){
- while(n % i == 0 && n > 1){
- n /= i;
- v[i]++;
- }
- }
- cout << "\n" << cp << " = ";
- for(int i = 2; i <= cp / 2; i++){
- if(v[i] != 0){
- if(ok)
- cout << " * ";
- cout << i << '^' << v[i];
- ok = 1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment