Skip to content

Instantly share code, notes, and snippets.

@CliffordAnderson
Created July 18, 2013 00:43
Show Gist options
  • Save CliffordAnderson/6025846 to your computer and use it in GitHub Desktop.
Save CliffordAnderson/6025846 to your computer and use it in GitHub Desktop.
Fizz Buzz in XQuery
xquery version "3.0";
(: Fizz Buzz in XQuery :)
for $i in (1 to 30)
return
if ($i mod 3 = 0 and $i mod 5 = 0) then "fizzbuzz"
else if ($i mod 3 = 0) then "fizz"
else if ($i mod 5 = 0) then "buzz"
else $i
@caschwartz
Copy link

Hi Cliff, I revisited the FizzBuzz puzzle on my way into work today (think we had this as an XQuery class assignment years ago). Happy to find we came up with the same solution in XQuery!

xquery version "1.0-ml";

(: FizzBuzz puzzle :)

for $num in (1 to 100)
return
if ($num mod 3 = 0 and $num mod 5 = 0) then
"FizzBuzz"
else if ($num mod 3 = 0) then
"Fizz"
else if ($num mod 5 = 0) then
"Buzz"
else $num

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment