#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1178
Task: [email protected]

Write a Python function that calculates the number of years remaining until retirement, given the current age, desired retirement age, and current savings with an annual interest ra
Generated: 2026-02-12T23:06:34.716302
"""

import math

def years_until_retirement(current_age, retirement_age, current_savings, annual_interest_rate, target_savings):
    years_needed = retirement_age - current_age
    if years_needed <= 0:
        return "Already at or past retirement age."

    # Calculate future savings with compound interest
    future_savings = current_savings * (1 + annual_interest_rate) ** years_needed

    if future_savings >= target_savings:
        return f"Will reach retirement in {years_needed} years with ${future_savings:.2f} savings."
    else:
        # Use logarithm to find the exact number of years needed to reach target savings
        years_needed_exact = math.log(target_savings / current_savings, 1 + annual_interest_rate)
        return f"Will need approximately {years_needed_exact:.2f} years to reach retirement savings."

if __name__ == '__main__':
    # Example data
    current_age = 30
    retirement_age = 65
    current_savings = 50000
    annual_interest_rate = 0.05  # 5%
    target_savings = 1000000

    result = years_until_retirement(current_age, retirement_age, current_savings, annual_interest_rate, target_savings)
    print(result)