Advertisement
rotti321

Teza 2 SIII ex 2

Jun 7th, 2021
115
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int numarare(int a, int b) {
  7. int ret = 0, aux, nr_div;
  8. if(a > b) {
  9. aux = b;
  10. b = a;
  11. a = aux;
  12. }
  13. for(int i = a; i <= b; i++) {
  14. nr_div = 0; ///cati divizori are i
  15. for(int d = 1; d <= i; d++) {
  16. if(i % d == 0) nr_div++;
  17. }
  18. if(nr_div == 3) ret++; ///daca are 3 div, il contorizam
  19. }
  20. return ret;
  21. }
  22.  
  23. int main(){
  24. int a, b;
  25. cin >> a >> b;
  26. cout << numarare(a, b);
  27. }
Advertisement
RAW Paste Data Copied
Advertisement