I guess this is a pretty silly question, but I'm having some trouble with Prolog.

countAux(_, [], 0).

countAux(D, [H|T], N) :-

D >= H,

DR is D - H,

countAux(DR, T, N1),

N is N1+1.

I'm trying to count the number of times (N) that I'll be able do subtract D from the elements of the list while D is greater the element H of the list.

For example, let's say I have countAux(300, [100, 190, 220], N).

N is supposed to be 2, because 300 - 100 = 200 and then 200 - 190 = 10, but 10 - 220 is less than zero so it should stop here.

The problem is that the code above is just returning "true" or "false" instead of the value of N.