fork download
  1. initial_balance_1 = 30000 # Starting amount in Account 1
  2. monthly_addition = 1000 # Monthly addition to Account 1
  3. daily_rate_1 = 0.16 / 365 # Daily interest rate for Account 1
  4. daily_rate_2 = 0.12 / 365 # Daily interest rate for Account 2
  5. years = 10 # Total duration in years
  6. days = years * 365 # Total number of days
  7. min_percentage = 0.1 # Minimum percentage required in Account 2
  8.  
  9. # Variables
  10. balance_1 = initial_balance_1 # Current balance in Account 1
  11. balance_2 = 0 # Current balance in Account 2
  12. total_interest_1 = 0 # Total interest earned by Account 1
  13. total_interest_2 = 0 # Total interest earned by Account 2
  14.  
  15. # Simulation
  16. for day in range(1, days + 1):
  17. # Calculate daily interest for Account 1
  18. interest_1 = balance_1 * daily_rate_1
  19. total_interest_1 += interest_1
  20.  
  21. # Transfer daily interest to Account 2
  22. balance_2 += interest_1
  23.  
  24. # Calculate daily interest for Account 2
  25. interest_2 = balance_2 * daily_rate_2
  26. total_interest_2 += interest_2
  27.  
  28. # Add daily interest to Account 2
  29. balance_2 += interest_2
  30.  
  31. # Ensure Account 2 has at least 10% of Account 1's balance
  32. if balance_2 < min_percentage * balance_1:
  33. deficit = min_percentage * balance_1 - balance_2
  34. balance_2 += deficit
  35. balance_1 -= deficit
  36.  
  37. # Add monthly addition to Account 1 on the first day of each month
  38. if day % 30 == 0:
  39. balance_1 += monthly_addition
  40.  
  41. # Results
  42. total_balance_1 = balance_1
  43. total_balance_2 = balance_2
  44. total_combined = total_balance_1 + total_balance_2
  45.  
  46. (total_balance_1, total_balance_2, total_interest_1, total_interest_2, total_combined)
  47. print(total_combined)
Success #stdin #stdout 0.01s 7336KB
stdin
Standard input is empty
stdout
391390.954958