title: Count the number of occurrences of a number in a list
body: <p>I'm writing a program in prolog that count the number of occurrences of a number in a list</p>
  
  <pre><code>count([],X,0).
  count([X|T],X,Y):- count(T,X,Z), Y is 1+Z.
  count([_|T],X,Z):- count(T,X,Z).
  </code></pre>
  
  <p>and this is the output</p>
  
  <pre><code>?- count([2,23,3,45,23,44,-20],X,Y).
  X = 2,
  Y = 1 ;
  X = 23,
  Y = 2 ;
  X = 23,
  Y = 1 ;
  X = 3,
  Y = 1 ;
  X = 45,
  Y = 1 ;
  X = 23,
  Y = 1 ;
  X = 44,
  Y = 1 ;
  X = -20,
  Y = 1 ;
  false.
  </code></pre>
  
  <p>it's count the same number several times</p>
  
  <p>Any help is appreciated</p>