💰

# Python で学ぶ FP: 資金計画を立てる際の 6 つの係数

2022/08/03に公開

## 終価係数

``````def shuka(nenri: float, year: int) -> float:
money = 1
for _ in range(year):
money *= 1 + nenri / 100
return money

for i in range(1, 6):
print(f"期間5年、年利{i}%の終価係数は{shuka(i, 5):.4f}")
``````
``````期間5年、年利1%の終価係数は1.0510

``````

## 現価係数

``````def genka(nenri: float, year: int) -> float:
money = 1
for _ in range(year):
money /= 1 + nenri / 100
return money

for i in range(1, 6):
print(f"期間5年、年利{i}%の現価係数は{genka(i, 5):.4f}")
``````
``````期間5年、年利1%の現価係数は0.9515

``````

## 年金終価係数

``````def shuka(nenri: float, year: int) -> float:
money = 1
for _ in range(year):
money *= 1 + nenri / 100
return money

def nenkin_shuka(nenri: float, year: int) -> float:
money = 0
for y in range(year):
money += shuka(nenri, y)
return money

for i in range(1, 6):
print(f"期間5年、年利{i}%の年金終価係数は{nenkin_shuka(i, 5):.4f}")
``````
``````期間5年、年利1%の年金終価係数は5.1010

``````

## 減債基金係数

``````def shuka(nenri: float, year: int) -> float:
money = 1
for _ in range(year):
money *= 1 + nenri / 100
return money

def nenkin_shuka(nenri: float, year: int) -> float:
money = 0
for y in range(year):
money += shuka(nenri, y)
return money

def gensai_kikin(nenri: float, year: int) -> float:
return 1 / nenkin_shuka(nenri, year)

for i in range(1, 6):
print(f"期間5年、年利{i}%の減債基金係数は{gensai_kikin(i, 5):.4f}")
``````
``````期間5年、年利1%の減債基金係数は0.1960

``````

## 資本回収係数

``````def shuka(nenri: float, year: int) -> float:
money = 1
for _ in range(year):
money *= 1 + nenri / 100
return money

def shihon_kaishu(nenri: float, year: int) -> float:
ratio = 0
for y in range(1, year + 1):
ratio += 1 / shuka(nenri, y)
return 1 / ratio

for i in range(1, 6):
print(f"期間5年、年利{i}%の資本回収係数は{shihon_kaishu(i, 5):.4f}")
``````
``````期間5年、年利1%の資本回収係数は0.2060

``````

## 年金現価係数

``````def shuka(nenri: float, year: int) -> float:
money = 1
for _ in range(year):
money *= 1 + nenri / 100
return money

def shihon_kaishu(nenri: float, year: int) -> float:
ratio = 0
for y in range(1, year + 1):
ratio += 1 / shuka(nenri, y)
return 1 / ratio

def nenkin_genka(nenri: float, year: int) -> float:
return 1 / shihon_kaishu(nenri, year)

for i in range(1, 6):
print(f"期間5年、年利{i}%の年金現価係数は{nenkin_genka(i, 5):.4f}")
``````
``````期間5年、年利1%の年金現価係数は4.8534

``````