This C++ program defines a function contor() that counts the number of divisors of an integer n using nested for loops. It then defines a function numarare() that counts the number of numbers between limits a and b that have exactly 3 divisors, by calling contor() and incrementing a counter. The main() function takes in two integers as input, calls numarare() to count numbers with 3 divisors between those limits, and outputs the final count.
This C++ program defines a function contor() that counts the number of divisors of an integer n using nested for loops. It then defines a function numarare() that counts the number of numbers between limits a and b that have exactly 3 divisors, by calling contor() and incrementing a counter. The main() function takes in two integers as input, calls numarare() to count numbers with 3 divisors between those limits, and outputs the final count.
This C++ program defines a function contor() that counts the number of divisors of an integer n using nested for loops. It then defines a function numarare() that counts the number of numbers between limits a and b that have exactly 3 divisors, by calling contor() and incrementing a counter. The main() function takes in two integers as input, calls numarare() to count numbers with 3 divisors between those limits, and outputs the final count.
int cnt=0; for(int d =1 ; d * d <= n ; d ++ ) if(n % d == 0) { ++cnt; if(d * d < n) ++cnt; } return cnt; } void numarare(int a, int b){ int cnt = 0; for(int i=a; i<=b; ++i){ if(contor(i) == 3) ++cnt; } cout << cnt; }
int a[100][100],v[1001]; int main(){ int n,d; cin >> n >> d; numarare(n,d); }