In this Kata, you have to make two predicates, is_odd/1 (I don't need to explain what it does, do I?) and odd_count/2, that returns the number of odd numbers below a certain value without including it.
For example:
odd_count(5,2) ---- 1 and 3
odd_count(6,3) ---- 1,3 and 5
Good luck!
is_odd(X) :- 1 is X mod 2. odd_count(N, R) :- is_odd(N) -> R is (N-1) div 2; R is N div 2.
- is_odd(X) :- 1 is X mod 2.
odd_count(N, R) :- is_odd(N) -> odd_count_recur(N, R); odd_count_recur(N + 1, R).odd_count_recur(0, 0) :- !.odd_count_recur(1, 0) :- !.odd_count_recur(N, R) :- N1 is N - 2, odd_count_recur(N1, R1), R is 1 + R1.- odd_count(N, R) :- is_odd(N) -> R is (N-1) div 2; R is N div 2.