rotti321

Nr de divizori

May 6th, 2021
440
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x,d=2,e,nrd=1;
  7.     cin>>x;
  8.     while(x!=1){
  9.         e=0;
  10.         while(x%d==0){
  11.             x=x/d;
  12.             e++; ///cresc exponentul lui d
  13.         }
  14.         if(e!=0){
  15.             nrd=nrd*(e+1);
  16.         }
  17.         d++; ///testez urmatorul factor prim
  18.     }
  19.     cout<<nrd;
  20.     return 0;
  21. }
RAW Paste Data