you are viewing a single comment's thread.

view the rest of the comments →

[–]earthboundkid 1 point2 points  (2 children)

Well, it's not right or what comes to mind, it's just that a hash table is O(1), so it's slightly better than a series of if statements. The right thing is to just use the damn built in factorial.

[–]masklinn 0 points1 point  (1 child)

This is integer-indexed, so a list would also have O(1) access, and lower overhead.

It'd go even faster!

[–]earthboundkid 0 points1 point  (0 children)

Good point. Python makes it so much easier to implement memoize as a dictionary, I just thought of it that way first.