Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

prolog help

Name: Anonymous 2012-05-03 22:56

So I was on this thread on /g/ where everybody was trying to solve the fizzbuzz problem in various languages, and I thought I'd try it in prolog. It seemed easy, but I couldn't even begin to solve it without causing errors or loops that I can't determine the cause of. If anyone isn't familiar, the goal is that for every number i in 1-100, if i is divisible by 3 you write
"fizz", 5 you write "buzz" (both if divisible by 15), or the value of i if neither. So I started with:

fizz(3). fizz(X) :- fizz(Y),X is Y + 3.
buzz(5). buzz(X) :- buzz(Y),X is Y + 5.

When I try to unify with "fizz(X),buzz(X)." it hangs and doesn't give me anything. Anyone know why?

Name: Anonymous 2012-05-04 7:35

So the stories were true.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List