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.