Created
November 24, 2019 14:27
-
-
Save senthilnowkb/5b609fbb5076865e8dab985094e61975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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