T = 8
ns = [1, 2, 3, 4, 5, 6, 7, 10]

def which_player_wins(n):
    moves = [2, 3, 5]
table = {j: '' for j in range(n + 1)}
table[0] = 'Second'
table[1] = 'Second'
for i in range(2, n + 1):
    next_n = [(i - move) for move in moves if i - move >= 0]
next_n_results = [table[k] for k in next_n]
if any([(result == 'Second') for result in next_n_results]):
    table[i] = 'First'
else:
    table[i] = 'Second'
return table[n]
for n in ns:
    pass
How to speed up a recursive algorithm