Prolog code to convert decimal number into its binary equivalent.
Domains
  N = integer
Predicates
  convert(N)
Clauses
  convert(0).
  convert(N):- R = (N mod 2),
        N1 = (N div 2),
        convert(N1),
        write(R).
Prolog code to take input from user at runtime.
Domains
  N,R = integer
Predicates
  fact(integer,integer)
  run
Clauses
  run:- write("Enter a positive number :"),
        readint(N),
        fact(N,R),
        write("Factorial of ",N," is ",R);
  fact(1,1).
  fact(N,R):- N1 = N-1,
        fact(N1,R1),
        R = R1*N.
Tower of Hanoi Problem
Domains
  N = integer
Predicates
  toh(integer,char,char,char)
Clauses
  toh(1,X,Y,_):-write("Move disk from "),
      write(X),
      write(" to "),
      write(Y),nl.
  toh(N,X,Z,Y):-N>1,
           M=N-1,
           toh(M,X,Y,Z),
           toh(1,X,Z,Y),
           toh(M,Y,Z,X).