The Average Value of Even Numbers That Are Divisible by Three interview question is a simple filtering and averaging task. Given an array of integers, you must find the average of all elements that are both even AND divisible by three. If no such numbers exist, the average is 0. This Average Value of Even Numbers That Are Divisible by Three coding problem tests basic loop and condition logic.
Accenture and IBM use this as an entry-level screening question. It ensures a candidate can correctly implement multiple conditions (logical AND) and handle edge cases like empty filtered lists (to avoid division by zero).
This utilizes the Array, Math interview pattern. The key logic is identifying that a number is both even and divisible by 3 if it is a multiple of 6 (n % 6 == 0). You iterate through the array once, maintain a sum and a count, and perform the division at the end.
Array: [1, 3, 6, 10, 12, 15]
Always combine multiple conditions into the most efficient form. Checking n % 6 == 0 is faster and cleaner than checking n % 2 == 0 && n % 3 == 0.