3 ms·
Some ruby code for those non-rubyists: (1..100) do |i| if i * 2 == 8 and i + 1 == 5 puts "foo" elsif i + 3 == 9 puts "bar" else
by mrchess 15y ago
Some ruby code for those non-rubyists:
(1..100) do |i|
if i * 2 == 8 and i + 1 == 5
puts "foo"
elsif i + 3 == 9
puts "bar"
else
puts i
end
end
Not the solution, but all the syntax you'll need in there.
- polyfractal 15y agoProbably should include the modulo operator too (Is it '%' ? I'm not a rubyist)
- mrchess 15y agoPart of the FizzBuzz test is to find out if the candidate is aware of modulo. :). But yeah it is %.
- polyfractal 15y agoOh man, I didn't even think of that. Such a basic concept...the mind reels. =(
- mikeknoop 15y agoI wouldn't really consider programmer == knows modulus. I only learned of the modulus operator a year or two ago (no formal CS background) and previously have built full scale web applications.