Advertisement
nikolalsvk

print_numbers

Aug 11th, 2023 (edited)
1,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.24 KB | None | 0 0
  1. def print_numbers
  2.   (1..100).each do |num|
  3.     output = ''
  4.  
  5.     output += 'APing' if num % 3 == 0
  6.     output += 'BPong' if num % 5 == 0
  7.  
  8.     if output.empty?
  9.       puts num
  10.     else
  11.       puts output
  12.     end
  13.   end
  14. end
  15.  
  16. print_numbers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement