Bob103

I-6

Feb 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int number_of_divisors(int x){
  4. int i, count = 0;
  5. for (i = 1; i*i < x; i++){
  6. if (x%i == 0)
  7. count += 2;
  8. }
  9. if (i*i == x)
  10. count++;
  11. return count;
  12. }
  13. int main()
  14. {
  15. int a, b, n;
  16. cout << "n=";
  17. cin >> n;
  18. cout << "a=";
  19. cin >> a;
  20. cout << "b=";
  21. cin >> b;
  22. int cnt = 0;
  23. for (int i = a; i <= b; i++)
  24. if (n==number_of_divisors(i))
  25. {
  26. cout << i << " " << number_of_divisors(i) << endl;
  27. cnt++;
  28. }
  29. if(cnt == 0)
  30. cout << "No divisors" << endl;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment