Finished math function. Was pretty hard to code math with javascript to get my output.