Skip to content

Instantly share code, notes, and snippets.

@XGFan
Last active March 23, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XGFan/aa58f92076f5a12e83fd46e6ba1f2b4e to your computer and use it in GitHub Desktop.
Save XGFan/aa58f92076f5a12e83fd46e6ba1f2b4e to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
//fmt.Println(700000 / 360)
//fmt.Println(700000 * 3.25 / 100 / 12)
//fmt.Println(700000/360 + 70*10000*3.25/100/12)
//每月公积金4000
repayment()
}
func repayment() {
total := 700000.0
rate := 3.25
account := 200000.0
income := 9000.0
var i int
f := total / 360
for i = 1; account <= total; i++ {
shouldPay := f + (total * rate / 100 / 12)
total -= total / 360
account += income - shouldPay
fmt.Println(i, "total:", total, "should", shouldPay, "account:", account)
if i%12 == 0 {
total -= account
account = 0
fmt.Println("Reload", "total:", total, "account:", account)
}
}
fmt.Println(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment