0 out of 464 challenges solved

Sum of Even Factors

Write a Python function `sum_of_even_factors(n)` that calculates the sum of all even factors of a given positive integer `n`. A factor of a number is an integer that divides the number without leaving a remainder. An even factor is a factor that is also an even number.

#### Example Usage
```python [main.nopy]
print(sum_of_even_factors(18))  # Output: 26 (2 + 6 + 18)
print(sum_of_even_factors(30))  # Output: 48 (2 + 6 + 10 + 30)
print(sum_of_even_factors(6))   # Output: 8 (2 + 6)
```

#### Constraints
- The input `n` will be a positive integer.
- The function should return `0` if there are no even factors.
def sum_of_even_factors(n):
    """
    Calculate the sum of all even factors of a given number.

    Args:
    n (int): The number to find even factors for.

    Returns:
    int: The sum of all even factors of n.
    """
    # Placeholder for the solution
    pass