Skip to content

Instantly share code, notes, and snippets.

@lancetw
Created February 14, 2017 03:19
Show Gist options
  • Save lancetw/6f87d2969ad2e2e4774aeefba5820f47 to your computer and use it in GitHub Desktop.
Save lancetw/6f87d2969ad2e2e4774aeefba5820f47 to your computer and use it in GitHub Desktop.
char** fizzBuzz(int n, int* returnSize) {
char** ret = calloc(n, sizeof(char*));
*returnSize = n;
char* sp;
for (int i = 1; i <= n; ++i) {
sp = *(ret + (i - 1)) = calloc(1, sizeof(char));
(i % 5 && i % 3) ? sprintf(sp, "%d", i) : sprintf(sp, "%s%s", (i % 3) ? "" : "Fizz", (i % 5) ? "" : "Buzz");
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment