Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ь, я, ей
var forms = 'рубль,рубля,рублей'.split(',')
/* Алгориииитм! */
function getForm(x) {
var x10 = x % 10, x100 = x % 100, form = 2 // рублей
if (x10 == 1 && x100 != 11)
form = 0 // рубль
else if (x10 > 1 && x10 < 5 && (x100 < 10 || x100 > 21))
form = 1 // рубля
return forms[form]
}
/* Ненаучный тест */
var res = ''
for (var i = 0; i < 26; ++i) {
res += i + ' ' + getForm(i) + '<br>'
}
res += '...<br>'
for (var i = 100; i < 126; ++i) {
res += i + ' ' + getForm(i) + '<br>'
}
document.getElementById('out').innerHTML = res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.