唯一分解定理

來源:互聯網
上載者:User

標籤:span   class   bing   特殊情況   .com   ==   info   http   技術分享   

唯一分解定理內容:每個正整數都可以分解成若干質數的乘積,質數從小到大排列(乘積可以是0,1,2......)

用數學式子表示則:對任一整數a>1,有a= (p1^a1)*(p2^a2)…(pn^an) ,其中p1<p2<…<pn均為素數,而a1,a2…,an是正整數。(1是個特殊情況,不算入)

那麼,背記重點來了:

1.a的正約數的個數:(每個都是從a0到an)

舉個例子:

  a=40=2^3*5^1;

  n=(1+3)(1+1)=8;

  1 40 2 20 4 10 5 8

2.a的正約數的和為:

  還是上面的例子

  sum=90;

  sum=(1+2+4+8)(1+5)=90,bingo!

3.a的歐拉函數

   fy(40)=16;

  fy(40)=2^2*5^0*(2-1)*(5-1)=16,bingo!

 

應用:

1.求n的質因數分解:

 1 k=2; 2 while (k*k<=a) 3     {if (a%k==0)  4         while (a%k==0) 5             { 6              a/=k; …//對因子重數的其他處理  7              } 8      k++; 9     }10 if (a>1) …//再對分解最後的那個質數進行處理 

2.求n的約數和

 1 int sum ( int n ) 2 {int k, res, tmp; 3  k=2; res=1; 4  while (k*k<=a) 5     {tmp=1; 6       while (n%k==0) {n/=k;tmp=tmp*k+1;}  7       res*=tmp; 8       k++; 9     }10  if (n>1)  res*=(1+n);11  return res;12 } 

 

 

唯一分解定理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.