Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def print_numbers
- (1..100).each do |i|
- if i % 3 == 0 && i % 5 == 0
- puts 'APingBPong'
- elsif i % 3 == 0
- puts 'APing'
- elsif i % 5 == 0
- puts 'BPong'
- else
- puts i
- end
- end
- end
- def print_numbers
- (1..100).each do |i|
- output = ''
- output += 'APing' if i % 3 == 0
- output += 'BPong' if i % 5 == 0
- puts(output.empty? ? i : output)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement