implement hofstadter q sequence