Advertisement
rotti321

T8 SIII ex 1

May 17th, 2021
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void nrfp( int n, int &m)
  5. { int nr, nrmax=0, i=2, x, d, p;
  6.     for(i=2; i<=n; i++)
  7.     { x=i;
  8.       d=2;
  9.       nr=0;
  10.        while(x!=1)
  11.        {    p=0;
  12.            while(x%d==0)
  13.            { p++;
  14.             x=x/d;
  15.            }
  16.            if(p!=0)
  17.             nr++;
  18.         d++;
  19.        }
  20.        if(nr>=nrmax)
  21.        {nrmax=nr;
  22.        m=i;
  23.            //cout<<nrmax<<' '<<m<<endl;
  24.        }
  25.        
  26.     }
  27. }
  28.  
  29. int main() {
  30.     int n=100, m;
  31.     nrfp(n,m);
  32.     cout<<m;
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement