Skip to content

Instantly share code, notes, and snippets.

@ifvictr
Last active February 16, 2021 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifvictr/e4991151b7838a4a1c63b1b2b59acf23 to your computer and use it in GitHub Desktop.
Save ifvictr/e4991151b7838a4a1c63b1b2b59acf23 to your computer and use it in GitHub Desktop.
FizzBuzz in JavaScript without any conditional statements. 174 bytes when minified.
p = ['Fizz', 'Buzz', '', 1]
c = Math.ceil
f = n =>
[
() => {},
() => {
a = n / 3
b = n / 5
console.log(
p[2 * (c(a) - ~~a)] +
p[1 + c(b) - ~~b] +
p[2 + (c(a) - ~~a) * (c(b) - ~~b)]
)
f(++p[3])
}
][c((x = n / 101)) - ~~x]()
_ = f(1)
p=["Fizz","Buzz","",1],c=Math.ceil,f=(z=>[()=>{},()=>{a=z/3,b=z/5,console.log(p[2*(c(a)-~~a)]+p[1+c(b)-~~b]+p[2+(c(a)-~~a)*(c(b)-~~b)]),f(++p[3])}][c(x=z/101)-~~x]()),_=f(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment