Advertisement
Guest User

fizzbuzz in rex

a guest
Aug 31st, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rexx 0.35 KB | None | 0 0
  1. call fizzbuzz 100
  2. return
  3.  
  4. fizzbuzz:
  5.     parse arg m
  6.     do n=1 to m
  7.         fb = maybe( dvd(n, 3), "Fizz" ) || maybe( dvd(n, 5), "Buzz" )
  8.         if fb == '' then
  9.             fb = n
  10.         say fb
  11.         end
  12.     return
  13.  
  14. dvd:
  15.     parse arg n, m
  16.     return (n // m) == 0
  17.  
  18. maybe:
  19.     parse arg p, t
  20.     if p then
  21.         return t
  22.     return ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement