Skip to content

Instantly share code, notes, and snippets.

@gyng
Last active September 26, 2020 19:31
Show Gist options
  • Save gyng/11a7533715037c26e714 to your computer and use it in GitHub Desktop.
Save gyng/11a7533715037c26e714 to your computer and use it in GitHub Desktop.
my not first fizzbuzz
% https://swish.swi-prolog.org/p/KDyjHEJd.pl
fizzbuzz(_, 0, 0, 'fizzbuzz').
fizzbuzz(_, 0, _, 'fizz').
fizzbuzz(_, _, 0, 'buzz').
fizzbuzz(X, _, _, X). % yuno what it is
buzzmyfizz(N) :-
FIZZ is N mod 3,
BUZZ is N mod 5,
fizzbuzz(N, FIZZ, BUZZ, R),
write(R), nl.
fizzmybuzz :-
foreach(between(1, 100, N), buzzmyfizz(N)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment