Hacker News new | ask | show | jobs
by tne 2784 days ago

  #include <stdlib.h>
  #include <stdio.h>
  
  static const char str[] = "fizzbuzz";
  
  static inline void out(int i, size_t offset, size_t sz)
  {
  	if (sz) {
  		fwrite(str + offset, sz, 1, stdout);
  	} else {
  		fprintf(stdout, "%d", i);
  	}
  	putchar('\n');
  }
  
  int main(void)
  {
  	for (int i = 1; i <= 100; i++) {
  		int a = i % 3 == 0;
  		int b = i % 5 == 0;
  		out(i, 4*((a^b)&b), 4*(a+b));
  	}
  	exit(0);
  }
There's a way to remove that conditional, too. Probably.