Created
October 11, 2013 10:57
-
-
Save alucky0707/6932932 to your computer and use it in GitHub Desktop.
PrologでFizzBuzz書きましたー。なんかPrologっぽくない
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fizzbuzz(N, "FizzBuzz") :- 0 is N mod 15, !. | |
fizzbuzz(N, "Fizz") :- 0 is N mod 3, !. | |
fizzbuzz(N, "Buzz") :- 0 is N mod 5, !. | |
fizzbuzz(N, X) :- swritef(Y, "%d", [N]), string_to_list(Y, X). | |
print_fizzbuzz(N) :- fizzbuzz(N, X), writef("%s", [X]), nl. | |
do_fizzbuzz :- foreach(between(1, 100, N), print_fizzbuzz(N)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment