Skip to content

Instantly share code, notes, and snippets.

@Doctor-Coomer
Created July 10, 2025 21:55
Show Gist options
  • Select an option

  • Save Doctor-Coomer/cbf3bba32c1b244b8dfb39a3dc54beff to your computer and use it in GitHub Desktop.

Select an option

Save Doctor-Coomer/cbf3bba32c1b244b8dfb39a3dc54beff to your computer and use it in GitHub Desktop.
Recursive main fizzbuzz
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
if (argv != NULL) argc = atoi(argv[1]);
if (argc <= 0) return 1;
const char* result = NULL;
if (argc%3 == 0 && argc%5 == 0) {
result = "FizzBuzz";
} else if (argc%3 == 0) {
result = "Fizz";
} else if (argc%5 == 0) {
result = "Buzz";
}
if (result) printf("%d - %s\n", argc, result);
else printf("%d - %d\n", argc, argc);
main(argc-1, NULL);
}
@Doctor-Coomer
Copy link
Author

Compile

$ gcc r_fizzbuzz.c
$ ./a.out 100
...
5 - Buzz
4 - 4
3 - Fizz
2 - 2
1 - 1

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