<commit_before>require 'factorial_3_ways/version'

module Factorial3Ways
  def factorial(method = :recursive)
    return 'Can not calculate factorial of a negative number' if self < 0
    method = :recursive unless [:loop, :inject, :recursive].include? method

    case method
    when :loop
      loop_method
    when :inject
      inject_method
    when :recursive
      recursive_method<commit_msg>default to inject over recursive, as inject doesn't have the same problems with super deep stacks<commit_after>require 'factorial_3_ways/version'

module Factorial3Ways
  def factorial(method = :inject)
    return 'Can not calculate factorial of a negative number' if self < 0
    method = :inject unless [:loop, :inject, :recursive].include? method

    case method
    when :loop
      loop_method
    when :inject
      inject_method
    when :recursive
      recursive_method
{'fraction_non_alphanumeric': 0.06363636363636363, 'fraction_numerical': 0.006818181818181818, 'mean_word_length': 3.636842105263158, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5142628', 'n_tokens_mistral': 261, 'n_tokens_neox': 245, 'n_words': 88}