Generation

generate functionWed, 25 Jan 2023

The number that has the maximum number of divisors inside an array

int maxDivisor(int arr[], int size) { int max = 0; //loop through array for(int i = 0; i < size; i++) { //count how many divisors int count = 0; for(int j = 1; j <= arr[i]; j++) { if(arr[i] % j == 0) { count++; } } //check if current number is greater than max if(count > max) { max = count; } } return max; }

Questions about programming?Chat with your personal AI assistant