Created
June 24, 2015 11:03
-
-
Save badamczewski/5978e8004f96ee061ffa to your computer and use it in GitHub Desktop.
branchless fizzbuzz.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object[] arr = new object[] { null, "fizz", "buzz", "fizzbuzz" }; | |
int r = 0; | |
int bf = 1; | |
int bb = 1; | |
int a1, a2 = 0; | |
for (int i = 1; i < 100000000; i++) | |
{ | |
a1 = a2 = 0; | |
if (bf > (3 - 1)) { bf = 0; a1 = 1; } | |
bf += 1; | |
if (bb > (5 - 1)) { bb = 0; a2 = 1; } | |
bb += 1; | |
r = a1 + a2 * 2; | |
arr[0] = i; | |
var s = arr[r]; | |
Console.WriteLine(s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment