Thanks for admitting this is homework. It's a refreshing breath of honesty for such questions.
I don't know where to start or how to start
Start with the links that marto just gave you, combined with the textbook or class notes from the class you are taking.
- Figure out the math for how to solve that problem manually. It is a simple math problem, and if you are advanced enough in your education to be taking a class on Perl programming, you should be able to solve it. If you need help with the math, perlmonks isn't really the place, because that's a math question, not a Perl programming question.
- Translate that math into Perl syntax. Your textbook or class notes should have examples of how to do the simple math functions required.