The first part can be done with computer program easily. (A while loop will do the trick)
e.g.
[code]
Assume N is the input number, P is a possible factor of N, PN is the number of count;

PN=0;
P=2;
while(P if(N%P==0){
  N=N/P;
  PN=PN+1;
}else{
  echo "*P^PN";
  PN=0;
  P=P+1;
}

}
[/code]
However, I do not fully understand what you mean in the second part of your question.