Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ping_pong(n)
- values = []
- (1..n).each do |num|
- ping = (num % 3 == 0)
- pong = (num % 5 == 0)
- if ping && pong
- values << 'APingBPong'
- elsif ping
- values << 'APing'
- elsif pong
- values << 'BPong'
- else
- values << num
- end
- end
- values
- end
- print ping_pong(100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement