Калькулятор сложных процентов

Рассчитывайте рост сложных процентов для инвестиций с течением времени.

Калькулятор сложных процентов показывает, как инвестиция или сберегательный счёт растут со временем, когда проценты начисляются не только на основную сумму, но и на накопленные проценты предыдущих периодов.

Введите основную сумму, годовую процентную ставку, частоту начисления (ежедневно, ежемесячно, ежеквартально или ежегодно) и количество лет. Калькулятор показывает итоговый баланс, общий доход от процентов и ежегодную разбивку.

Понимание сложных процентов необходимо для планирования выхода на пенсию, оценки сберегательных счетов, сравнения стоимости кредитов и принятия обоснованных инвестиционных решений.

Часто задаваемые вопросы

Реализация кода

def compound_interest(principal, annual_rate, years, n=12, contribution=0):
    """
    Calculate compound interest with optional regular contributions.

    Parameters:
        principal    - initial investment
        annual_rate  - annual interest rate (e.g. 0.07 for 7%)
        years        - investment duration in years
        n            - compounding frequency per year (12 = monthly)
        contribution - periodic contribution (same frequency as n)

    Returns dict with final balance, total invested, and total interest.
    """
    r = annual_rate / n
    periods = int(years * n)
    balance = principal
    for _ in range(periods):
        balance = balance * (1 + r) + contribution
    total_invested = principal + contribution * periods
    return {
        "final_balance":  balance,
        "total_invested": total_invested,
        "total_interest": balance - total_invested,
    }

def rule_of_72(annual_rate):
    """Estimate years to double at a given annual rate."""
    return 72 / (annual_rate * 100)

# Simple formula (no contributions)
def compound_formula(P, r, n, t):
    """A = P(1 + r/n)^(nt)"""
    return P * (1 + r / n) ** (n * t)

# Examples
result = compound_interest(10000, 0.07, 20, n=12, contribution=500)
print(f"Final balance:   ${result['final_balance']:,.2f}")
print(f"Total invested:  ${result['total_invested']:,.2f}")
print(f"Total interest:  ${result['total_interest']:,.2f}")
print(f"Years to double: {rule_of_72(0.07):.1f} years at 7%")

# Compounding frequency comparison
for label, n in [("Annual", 1), ("Monthly", 12), ("Daily", 365)]:
    A = compound_formula(10000, 0.12, n, 10)
    print(f"{label:8}: ${A:,.2f}  (EAR = {((1 + 0.12/n)**n - 1)*100:.4f}%)")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.