fact = Hash.new {|h,k| h[k] = if k > 1: k*h[k-1] else 1 end }p fact # {}: it starts off emptyp fact[4] # 24: 4! is 24p fact # {1=>1, 2=>2, 3=>6, 4=>24}: the hash now has entries