#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1139
Task: [
</think>

Write a Python function that calculates the next financial milestone toward retirement based on current savings, monthly contributions, and annual interest rate.
Generated: 2026-02-12T21:40:31.405970
"""

import math

def calculate_retirement_milestone(current_savings, monthly_contribution, annual_interest_rate, target_savings):
    """
    Calculates the number of months needed to reach a target savings amount for retirement.
    
    Parameters:
    current_savings (float): The current amount saved.
    monthly_contribution (float): Monthly contribution to savings.
    annual_interest_rate (float): Annual interest rate (as a decimal).
    target_savings (float): Target savings amount for retirement.
    
    Returns:
    int: Number of months needed to reach the target savings.
    """
    monthly_interest_rate = annual_interest_rate / 12
    months = 0
    savings = current_savings
    
    while savings < target_savings:
        savings += monthly_contribution
        savings *= (1 + monthly_interest_rate)
        months += 1
    
    return months

if __name__ == '__main__':
    # Example test data
    current_savings = 50000
    monthly_contribution = 2000
    annual_interest_rate = 0.05
    target_savings = 1000000
    
    months_needed = calculate_retirement_milestone(current_savings, monthly_contribution, annual_interest_rate, target_savings)
    print(f"Months needed to reach retirement target: {months_needed}")