log2(I,E):-
(
number(I)
-> E is log(I)/log(2);
number(E)
-> I is 2**E
).
lgstar(N,A):-
(N>1
->
(
log2(N,Nprev),
lgstar(Nprev,Aprev),
Aprev is A-1
);
A is 0
).
Log * is the number of times a log must be applied to a value until it is less than or equal to 1.
For Example:
log(log(log(log(3000)))) = 0.86364760439
so the log * (3000) = 4
From my understanding of the way recursion in prolog works when I get to the base case of N<1 the A should be returned and on the next level of the stack the Aprev should be inferred to be A +1 or Aprev is 1 and so on until it reaches the top of the stack where A is returned.
Query:
lgstar(3000,A)
--> Should be 4
When I reach the case that N<1 then I try to return 0 to the previous layer on the stack instead I get an arguments are not sufficiently instantiated error.