Skip to content

Instantly share code, notes, and snippets.

@suissa
Created February 22, 2020 03:53
Show Gist options
  • Save suissa/a98195b8aa18103e6ed0c9d4e07434c2 to your computer and use it in GitHub Desktop.
Save suissa/a98195b8aa18103e6ed0c9d4e07434c2 to your computer and use it in GitHub Desktop.
Demonstração de como criar operações básicas de matemática usando Arrays - divisão
// const dividir = (x, y, passos = 0, total = 0) => {
// const lista = crieUmaListaDeTamanho(x).ePreenchaCom(y)
// while(total < x) {
// total += lista[passos]
// passos++
// }
// return passos
// }
const dividir = (x, y, passos = 0, total = 0) => {
const lista = crieUmaListaDeTamanho(x).ePreenchaCom(y)
const resultado = lista.filter(n => {
total = total + n
return total <= x
})
return resultado.length
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment