Write a function:
def solution(N):
that, given a positive integer N, returns the number of its even factors.
For example, given N = 16, the function should return 3, because among all factors of 16 (1, 2, 4, 8, 16), only three factors (2, 4, 8) are even numbers.
Here's an inefficient solution:
```
def solution(N):
count = 0
# Check all numbers from 1 to N
for i in range(1, N + 1):
# Check if i is a factor of N
if N % i == 0:
# Check if the factor is even
if i % 2 == 0:
count += 1
return count
```
The above solution works correctly but is highly inefficient for large numbers as it:
- Checks every number from 1 to N
- Makes unnecessary iterations
- Has a time complexity of O(N)
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..2,147,483,647]