#include <iostream>
#include <map>

using namespace std;

map<int,int> factorFactor(int n)
{
    map<int,int> M;
    for(int m = 2; m <= n; ++m)
    {
        int d = m;
        for(int i = 2; i*i <= d; ++i)
        {
            if (d%i) continue;
            while(d%i == 0)
            {
                M[i]++;
                d /= i;
            }
        }
        if (d > 1) M[d]++;
    }
    return M;
}

int main(int argc, char * argv[])
{
    auto m = factorFactor(10);
    for(auto x: m)
    {
        cout << x.first << "^" << x.second << "  ";
    }
    cout << "\n\n\n";
    
    m = factorFactor(100);
    for(auto x: m)
    {
        cout << x.first << "^" << x.second << "  ";
    }
    cout << "\n";
    
}
