I think you misunderstood my post above - while I and many others on this forum are happy to help with Julia-specific coding questions, as people have done in this thread and the other thread you opened on the same topic, you will not get a solution to your homework problem here. I should also note again that you are violating the rules set out on your assignment (as posted here) which clearly state that the solution should be your own.
I have explained above what your “mistake” is as far as the Julia coding part goes, working out what these boundary conditions should be to avoid the BoundsError
seems to be exactly what the question is asking for.