Skip to content

Instantly share code, notes, and snippets.

@WellCod
Created April 23, 2014 14:38
Show Gist options
  • Save WellCod/11217892 to your computer and use it in GitHub Desktop.
Save WellCod/11217892 to your computer and use it in GitHub Desktop.
Ruby.upto
print "Digite a quantidade de casas decimais desejadas: "
nr_casas = gets.chomp.to_i
potencia = (10**nr_casas)
0.upto(potencia) do |numero|
numero_exibicao = "%1.#{nr_casas}f" % (numero.to_f / potencia)
puts numero_exibicao
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment