yoyoboyss

Untitled

May 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <iostream.h>
  2.  
  3. void main(){
  4. int n, cp, ok = 0;
  5. int v[100000];
  6.  
  7. cout << "n= "; cin >> n;
  8. cp = n;
  9. for(int i = 2; i <= cp / 2; i++){
  10. while(n % i == 0 && n > 1){
  11. n /= i;
  12. v[i]++;
  13. }
  14. }
  15. cout << "\n" << cp << " = ";
  16. for(int i = 2; i <= cp / 2; i++){
  17. if(v[i] != 0){
  18. if(ok)
  19. cout << " * ";
  20. cout << i << '^' << v[i];
  21. ok = 1;
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment