More than 3 years have passed since last update.
self-rec-fizz-buzz.rb
n = 1
if n%15 == 0
puts "FizzBuzz"
elsif n%3 == 0
puts "Fizz"
elsif n%5 == 0
puts "Buzz"
else
puts n
end
if n == 100
n = 1
cmd = "exit"
else
n += 1
cmd = "system('exec ruby #{__FILE__}')"
end
lines = File.readlines(__FILE__)
lines[0] = "n = #{n}\n"
File.write(__FILE__, lines.join)
eval cmd
Why not register and get more from Qiita?
- We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
- you can read useful information later efficiently
By "stocking" the articles you like, you can search right away
Sign upLogin