Advertisement
STANAANDREY

T19XI2018

Nov 19th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     unsigned long n,k,nr=1,d,nrdiv;
  8.  
  9.     cout<<"n=";cin>>n;
  10.     cout<<"k=";cin>>k;
  11.  
  12.     while (nr<=n)
  13.     {
  14.         nrdiv=2;
  15.         d=nrdiv;
  16.         while (d<=nr/2)
  17.         {
  18.             if (nr%d==0)
  19.                 nrdiv++;
  20.             d++;
  21.         }
  22.         if (nrdiv==k)
  23.             cout<<nr<<" ";
  24.      nr++;
  25.     }
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement