User blog comment:VoidSansXD/My attempt at not creating a recursive function/@comment-37246647-20190209234852/@comment-37246647-20190210034418

No, not at all. When you get to the prime number, count the steps before the last non-prime, double the last non-prime, and add the two numbers together. Simple as that.