Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Проверка валидности ИНН юрлица на Ruby (согласно
def valid_le_tax_id? (tax_id)
tax_id = tax_id.to_s.split('')
weights = [2,4,10,3,5,9,4,6,8,0]
sum = tax_id.each_with_index.reduce(0){|result,item|
result += item[0].to_i * weights[item[1]]
return sum == tax_id[9].to_i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment