Skip to content

Instantly share code, notes, and snippets.

@senthilnowkb
Created November 24, 2019 14:27
Show Gist options
  • Save senthilnowkb/5b609fbb5076865e8dab985094e61975 to your computer and use it in GitHub Desktop.
Save senthilnowkb/5b609fbb5076865e8dab985094e61975 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math"
)
// Don't use float32
// float64 precision is required for this to work correctly
func PMT(p, r, n float64) float64 {
return (p * r) / (1 - math.Pow((1+r), -n))
}
func GetEMI(p, r, n float64) float64 {
return PMT(p, (r/100.0)/(365.0/30.0), n)
}
func main() { // P, r, n, l
k := GetEMI(20000.0, 30, 3)
fmt.Printf("k %g \n", k)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment