试除法分解质因数

void divide(int x)
 {
 
    for (int i = 2; i <= x / i; i ++ )
        if (x % i == 0)
        {
            int s = 0;
            while (x % i == 0) x /= i, s ++ ;
            cout << i << ' ' << s << endl;
        }
    if (x > 1) cout << x << ' ' << 1 << endl;
    cout << endl;
}
posted on 2025-07-24 00:14  下头小美  阅读(3)  评论(0)    收藏  举报