Hi
This sounds like home work; but anyway:
Read
this which explains the technique of bash recursion and calling a function within itself.
Also what would make the solution even better is
this - which is a mathematical formula that adds numbers from 1..n