# Bug with LinearRecurrence and Slot/SlotSequence?

The code below runs without any error:

LinearRecurrence[{##}, {1}, 5]


Each term is the previous term squared, times the index of the previous term.

If the ## is substituted with ##2 or ##3, the code returns an array of 1s. ##4 or higher SlotSequences throw errors.

I'm sure this is a bug, but I don't understand why this is happening; Trace doesn't seem to reveal anything. Why does the above code behave that way?

• Also, LinearRecurrence[{#}, {1}, 5] outputs the same thing as Factorial. – JungHwan Min May 22 '17 at 15:09
• Using a symbolic starting value might be more informative: LinearRecurrence[{##2}, {C[1]}, 5]. – J. M.'s technical difficulties May 22 '17 at 15:36
• Is this undocumented functionality? I don't see anything in the function docs for LinearRecurrence, and I can't think of any other documented functions where you use Slot or SlotSequence outside of Function. – Pillsy May 22 '17 at 16:52
• Funnily enough, DifferenceRoot[Function[{a, n}, {a[n + 1] == ## a[n], a[1] == 1}]][ Range[5]] and LinearRecurrence[{##}, {1}, 5] give the same results. This is very peculiar indeed. – J. M.'s technical difficulties Nov 19 '19 at 9:35