As I think this is how it should be. I don't have SQL in my PC to check it.
1. Write a function that takes one integer(number_of_credits) as a parameter.
https://www.simple-talk.com/sql/t-sql-programming/sql-server-functions-the-basics/
Inside the function
1. create two variables as LstNo -...