Last active
February 28, 2025 07:43
Revisions
-
thinkphp renamed this gist
Feb 28, 2025 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
thinkphp created this gist
Feb 26, 2025 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #include <iostream> using namespace std; int vec[1001], d, m, n, x; int main() { cout << "n ( <=1000 ) = "; cin >> n; for (int tt = 2; tt <= n; ++tt) { x = tt; for (d = 2; x > 1; d++) { for (m = 0; (x % d) == 0; m++, x /= d); vec[d] += m; // Accumulate the factor counts } } cout << n << "! prime factorization:\n"; for (d = 2; d <= n; ++d) { if (vec[d]) cout << d << "^" << vec[d] << endl; } return 0; }