什么是“复利”?
复利是在贷款或存款的本金中加上利息,或者换句话说,是利息。这是将利息再投资而不是付清利息的结果,因此,下一个期间的利息将以本金加上先前累计的利息来赚取。复利是金融和经济学的标准。
复利可能与单利形成对比,在这种情况下,利息未添加到本金,因此不存在复利。
复利公式:
Formula to calculate compound interest annually is given by:
Compound Interest = P(1 + R/100)r
Where,
P is principle amount
R is the rate and
T is the time span
伪代码:
Input principle amount. Store it in some variable say principle.
Input time in some variable say time.
Input rate in some variable say rate.
Calculate compound interest using formula,
Compound Interest = principle * (1 + rate / 100) time).
Finally, print the resultant value of CI.
例子:
Input : Principle (amount): 1200
Time: 2
Rate: 5.4
Output : Compound Interest = 1333.099243
C++
// CPP program to find compound interest for
// given values.
#include
using namespace std;
int main()
{
double principle = 10000, rate = 10.25, time = 5;
/* Calculate compound interest */
double CI = principle * (pow((1 + rate / 100), time));
cout << "Compound interest is " << CI;
return 0;
}
Java
// Java program to find compound interest for
// given values.
import java.io.*;
class GFG
{
public static void main(String args[])
{
double principle = 10000, rate = 10.25, time = 5;
/* Calculate compound interest */
double CI = principle *
(Math.pow((1 + rate / 100), time));
System.out.println("Compound Interest is "+ CI);
}
}
// This code is contributed by Anant Agarwal.
Python3
# Python3 program to find compound
# interest for given values.
def compound_interest(principle, rate, time):
# Calculates compound interest
CI = principle * (pow((1 + rate / 100), time))
print("Compound interest is", CI)
# Driver Code
compound_interest(10000, 10.25, 5)
# This code is contributed by Abhishek Agrawal.
C#
// C# program to find compound
// interest for given values
using System;
class GFG {
// Driver Code
public static void Main()
{
double principle = 10000, rate = 10.25, time = 5;
// Calculate compound interest
double CI = principle * (Math.Pow((1 +
rate / 100), time));
Console.Write("Compound Interest is "+ CI);
}
}
// This code is contributed by Nitin Mittal.
PHP
Javascript
输出:
Compound interest is 16288.9