This time, as an example, consider a number that is double the input value with three digits padded with zeros. 1→002 2→004 6→012
1→2 2→4 6→12 First, enable
puts "please put numbers"
number = gets.to_i
number2=number*2
print number2
↑ This completes.
sprintf("%03d",number)
Or
"%03d" % number
However, the number is displayed in 3 digits with 0 padding.
puts "please put numbers"
number = gets.to_i
number2=number*2
number3=sprintf("%03d", number2)
print number3
1→002 2→004 6→012
Was confirmed
http://osishow3.hateblo.jp/entry/2017/04/24/235500
https://www.setoya-blog.com/entry/2013/12/06/171143