document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. #define MAX_PRIME 101
  6.  
  7. int main() {
  8.     int N;
  9.     while(cin>>N && N!=0){
  10.         int primeSeq[MAX_PRIME] = {0};
  11.         int sqrt_N = sqrt((double) N);
  12.  
  13.         for(int n=N; n>1; n--){
  14.             int temp = n;
  15.             for(int f=2;f<=sqrt_N && f<temp;f++){
  16.                 while( temp%f == 0){
  17.                     primeSeq[f]++;
  18.                     temp/=f;
  19.                 }
  20.             }
  21.             if(temp>1){
  22.                 primeSeq[temp]++;
  23.             }
  24.         }
  25.  
  26.         cout.width(3);
  27.         cout<<N<<"! =";
  28.         int changeLineCount = 0;
  29.         for(int i=0;i<MAX_PRIME;i++){
  30.             if(primeSeq[i]>0){
  31.                 if(changeLineCount%15==0 && changeLineCount!=0){
  32.                     cout<<endl<<"      ";
  33.                 }
  34.                 changeLineCount++;
  35.  
  36.                 cout.width(3);
  37.                 cout<<primeSeq[i];
  38.             }
  39.         }
  40.         cout<<endl;
  41.     }
  42.  
  43.     return 0;
  44. }
');