How can I write an efficient procedural prolog program to find the next biggest number using the same digits?
For an example : Input : ?- next_num([1,2,3,4],N). Then