#P1163. Loan Interest Rate Calculation
Loan Interest Rate Calculation
Loan Interest Rate Calculation
After taking a loan from a bank, a borrower must repay the loan with a fixed monthly installment over a period. Given the principal amount P, the fixed monthly payment A, and the number of months n, calculate the monthly interest rate that the borrower is actually paying (in percentage). Assume the interest is compounded monthly.
The monthly installment is given by the formula:
\( A = \frac{P \times r \times (1+r)^n}{(1+r)^n - 1} \)
Here, r is the monthly interest rate (in decimal form). You are required to compute r and output it as a percentage with 6 decimal places. For instance, if r = 0.015, then output 1.500000.
inputFormat
The input consists of a single line containing three space-separated values:
- P: the loan principal (a positive floating-point number)
- A: the fixed monthly payment (a positive floating-point number)
- n: the number of months (a positive integer)
outputFormat
Output the monthly interest rate (as a percentage) accurate to 6 decimal places.
sample
10000 500 24
1.500000