module FFaker::ModuleUtils
def luhn_check(number)
def luhn_check(number) multiplications = [] number.split(//).each_with_index do |digit, i| multiplications << i.even? ? digit.to_i * 2 : digit.to_i end sum = 0 multiplications.each do |num| num.to_s.each_byte do |character| sum += character.chr.to_i end end control_digit = (sum % 10).zero? ? 0 : (sum / 10 + 1) * 10 - sum control_digit.to_s end