Generation

generate functionThu, 10 Nov 2022

Given an integer N, the task is to find the number of divisors of N which are divisible by 2.

void countDiv(int N) { // Variable to store the // count of numbers int cnt = 0; // For every number which // is divisible by 2 for (int i = 2; i <= N; i += 2) if (N % i == 0) cnt++; // Return the count System.out.print(cnt); }

Questions about programming?Chat with your personal AI assistant