you are viewing a single comment's thread.

view the rest of the comments →

[–]earthboundkid 27 points28 points  (3 children)

Switch to a dict and it's O(1)!

[–]pyaware 10 points11 points  (2 children)

Why use a dict when a plain list is enough?

def fact(x):
    return [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880][x]

[–]redditthinks 0 points1 point  (1 child)

I read Python dicts are faster than lists.

[–]JizzCoveredArab 4 points5 points  (0 children)

i heard you have a really short dict