It is possible to shortcut the sequence by omitting the 1s, since the number of 1s at any point can be pre-computed. If we have a least-prime-divisor function lpd, then Vladimir Shevelev describes the sequence as a1 = lpd(6-1) = 5, a2 = lpd(6-2+5) = 3, a3 = lpd(6-3+5+3) = 11, a4 = lpd(6-4+5+3+11) = 3, a5 = lpd(6-5+5+3+11+3) = 23, …, and an = lpd(6 – n + sum(a1 … an-1).

Your task is to write functions that generate the three sequences, including the shortcut. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Posted on pastebin.com, since my line count stretches the limits of polite posting here.
I memoized nearly everything, trading time for space. Python has syntactic sugar called “decorators” that works nicely for this; after defining
a decorator memoize(func), one merely need write @memoize on the line above the function definition to cache the result of calling func()
for later recursion or reuse.

Rather quick, though not as elegant or speedy as the Scheme or Haskell answers. I bet the F# answer probably wins over mine as well, but I
haven’t the ability to run F# on my laptop just yet.