Write recursive fizzbuzz in C
- User
Write recursive fizzbuzz in C
Assistant
Here is recursive fizzbuzz in C:
void fizzbuzz(int n) { if (n == 0) return; if (n % 15 == 0) printf("fizzbuzz\n"); else if (n % 3 == 0) printf("fizz\n"); else if (n % 5 == 0) printf("buzz\n"); else printf("%d\n", n); fizzbuzz(n - 1); }This recursively prints fizzbuzz for numbers divisible by 15, fizz for numbers divisible by 3, buzz for numbers divisible by 5, and the number itself for other numbers, counting down from the input n to 1.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.