Advertisement
totobac

Untitled

Nov 13th, 2021
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. int getNumberOfDivisors(int num) {
  2. if (num < 2)
  3. return num;
  4.  
  5. int result = 2;
  6. for (size_t i = 2; i <= num / 2 ; i++)
  7. {
  8. if (num % i == 0)
  9. result++;
  10. }
  11. return result;
  12. }
  13.  
  14. bool checkNumberOfDivisors(int a, int b, int k) {
  15. for (size_t i = a; i <= b; i++)
  16. {
  17. if (getNumberOfDivisors(i) < k)
  18. return false;
  19. }
  20. return true;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement