General FizzBuzz: Difference between revisions
Content added Content deleted
Line 2,526: | Line 2,526: | ||
A simple Prolog solution to the generalised FizzBuzz problem is as follows: |
A simple Prolog solution to the generalised FizzBuzz problem is as follows: |
||
<lang prolog> |
<lang prolog>go :- maxNumber(M), factors(Fs), MLast is M+1, loop(1,MLast,Fs). |
||
⚫ | |||
⚫ | |||
⚫ | |||
loop(B,B,_). |
loop(B,B,_). |
||
Line 2,536: | Line 2,533: | ||
Next is A+1, loop(Next,B,Fs). |
Next is A+1, loop(Next,B,Fs). |
||
fizzbuzz(_,[],""). |
|||
go :- maxNumber(M), factors(Fs), MLast is M+1, loop(1,MLast,Fs).</lang> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
The program can be launched by querying the predicate |
|||
<lang prolog>?- go.</lang> |
|||
It is worth noting that |
It is worth noting that |