This week's code snippet, Fizz Buzz in Prolog, is brought to you by Subete and the Sample Programs repo.
% Portions of this solution were derived through the assistance of ChatGPT.
:- initialization(main).
fizzbuzz(N) :-
fizzbuzz_helper(1, N).
fizzbuzz_helper(X, N) :-
X > N, !.
fizzbuzz_helper(X, N) :-
(X mod 15 =:= 0 ->
write('FizzBuzz'), nl
; X mod 3 =:= 0 ->
write('Fizz'), nl
; X mod 5 =:= 0 ->
write('Buzz'), nl
;
write(X), nl
),
X1 is X + 1,
fizzbuzz_helper(X1, N).
main() :-
fizzbuzz(100),
halt.
Below you'll find an up-to-date list of articles by me on The Renegade Coder. For ease of browsing, emojis let you know the article category (i.e., blog: ✒️, code: 💻, meta: 💭, teach: 🍎)
- 💭 2024: Year in Review
- ✒️ Is Anyone Else Bothered by How Quickly We Adopted Generative AI?
- ✒️ 31 Lessons Learned as a New Dad
- 🍎 So You’re Not Sure If Computer Science Is for You
- 🍎 You Should Give Open-Ended Projects to Your Students
- 💻 How to Move Your Extensions Folder in VS Code
- 💭 Sample Programs Repo Celebrates 1,000 Code Snippets
- 🍎 Canvas Is Not Built With Educators in Mind
- 💻 Workshopping a Tier List Generator
- ✒️ No, The GRE Should Not Be Reinstated
Also, here are some fun links you can use to support my work.
This document was automatically rendered on 2025-02-21 using SnakeMD.