Skip to content

Instantly share code, notes, and snippets.

@dvbeato
Created April 28, 2015 01:40
Show Gist options
  • Select an option

  • Save dvbeato/534ecf37ec546b19cd11 to your computer and use it in GitHub Desktop.

Select an option

Save dvbeato/534ecf37ec546b19cd11 to your computer and use it in GitHub Desktop.
object CaixaEletronico {
def main(args: Array[String]) {
val valorSaque = args(0).toInt
val notas = List(100,50,20,10)
def quantidade(notas:List[Int], valorSaque:Int): List[Int] = notas match {
case Nil => List()
case valorNota::notas => {
List(valorSaque / valorNota) ++ quantidade(notas, valorSaque - valorNota * (valorSaque / valorNota))
}
}
println(quantidade(notas, valorSaque))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment