Solved SPP linear recursive function