first decide the nuber of counter bits. you said 5 bit.
then implement a state machine as,
1. first it will be in initial state. here preset the counter.
2. then counter shold start. for this have one more state.
3. once it reaches the max limit, the counter should start from preset value and again it should count. for this we can have one more state.
like this we can implement for programmable down counter or even we can mix up & down counter.(programmable).
i wish it will hwllp you.