Finished product (except one small thing)

Need to add the case where the tail is 1 and you go back on yourself...