Facebook
From Muhammad Moawaz Ayub, 3 Weeks ago, written in Ruby.
Embed
Download Paste or View Raw
Hits: 50
  1. def foo
  2.   (1..100).each do |num|
  3.     if is_zero(num, 3) && is_zero(num, 5)
  4.       p 'PingPong'
  5.     elsif is_zero(num, 3)
  6.       p 'Ping'
  7.     elsif is_zero(num, 5)
  8.       p 'Pong'
  9.     else
  10.       p num
  11.     end
  12.   end
  13. end
  14.  
  15. def is_zero(num, denominator)
  16.   (num%denominator) == 0
  17. end
  18.  
  19. foo