Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program :- read(L), read(A), read(B), rentang(L,A,B,C), write(C), nl.
- rentang([],_,_,0).
- rentang([H|T],1,1,H).
- rentang([H|T],1,B,C):- Y is B-1, rentang(T,1,Y,E), C is H+E.
- rentang([H|T],A,B,C):- X is A-1, Y is B-1, rentang(T,X,Y,C).
- :- program.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement