ValerianBenchea

Nr. de divizori ai numerelor cuprinse in intervalul a b

Dec 4th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a, b, n, r, d;
  8.     cin>>a>>b;
  9.     for(n=a; n<=b; n++)
  10.     {
  11.         r=0;
  12.         for(d=2; d<=n/2; d++)
  13.         {
  14.             if(n%d==0)
  15.             r++;
  16.         }
  17.         cout<<r<<" ";
  18.     }
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment