
4.1k Views
954 Executions
Does it work?
No reports yetNo reports yet. Tried it? Be the first to say.
Also noticed:
Description
Ji
-- Auto JJS de EB até 5000 | Script por ChatGPT
-----------------------------
-- Função para converter número em extenso (até 5000)
-----------------------------
local function numeroPorExtenso(n)
local unidades = {
"zero","um","dois","três","quatro","cinco","seis","sete","oito","nove"
}
local especiais = {
[10]="dez",[11]="onze",[12]="doze",[13]="treze",[14]="quatorze",
[15]="quinze",[16]="dezesseis",[17]="dezessete",[18]="dezoito",[19]="dezenove"
}
local dezenas = {
[2]="vinte",[3]="trinta",[4]="quarenta",[5]="cinquenta",
[6]="sessenta",[7]="setenta",[8]="oitenta",[9]="noventa"
}
local centenas = {
[1]="cem",[2]="duzentos",[3]="trezentos",[4]="quatrocentos",
[5]="quinhentos",[6]="seiscentos",[7]="setecentos",
[8]="oitocentos",[9]="novecentos"
}
local texto
if n < 10 then
texto = unidades[n+1]
elseif n < 20 then
texto = especiais[n]
elseif n < 100 then
local d, u = math.floor(n/10), n%10
if u == 0 then
texto = dezenas[d]
else
texto = dezenas[d].." e "..unidades[u+1]
end
elseif n < 1000 then
local c, resto = math.floor(n/100), n%100
if n == 100 then return "CEM" end
if resto == 0 then
texto = centenas[c]
Comments
0Log in to join the conversation. Login
No comments yet. Be the first!








