This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 練習:請印出從 1 到 100 之間所有的單數。 | |
array_1_to_100=[*1..100] | |
array_1_to_100_odd=array_1_to_100.select{|a| a%2==1} | |
p array_1_to_100_odd | |
# 練習:請印出從 1 到 100 之間所有的單數的總和。 | |
sum=0 | |
for i in 1..100 do |