use non-recursive algorithm for generate_bell