Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to convert decimal number to roman number

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 5036

Program to convert decimal number to roman number........

Code for ProLog Program to convert decimal number to roman number in Artificial Intelligence

predicates
  transform(integer)

clauses
  transform(X) :- X >= 1000, write("M"),  Y=X-1000,  transform(Y).
  transform(X) :- X >=  900, write("CM"), Y=X-900,   transform(Y).
  transform(X) :- X >=  500, write("D"),  Y=X - 500, transform(Y).
  transform(X) :- X >=  400, write("CD"), Y=X-400,   transform(Y).
  transform(X) :- X >=  100, write("C"),  Y=X-100,   transform(Y).
  transform(X) :- X >=   50, write("L"),  Y=X-50,    transform(Y).
  transform(X) :- X >=   40, write("XL"), Y=X-40,    transform(Y).
  transform(X) :- X >    9, write("X"),  Y=X-10,    transform(Y).
  transform(X) :- X =    9, write("IX"), nl.
  transform(X) :- X >    4, write("V"),  Y=X-5,     transform(Y).
  transform(X) :- X =    4, write("IV"),nl.
  transform(X) :- X >=   1, write("I"),  Y=X-1,     transform(Y).
  transform(X) :- X =    0, nl.
  transform(X) :- X <    0, write("-"), Y=-X, transform(Y).

goal
   transform(75).
  
Share: 


Didn't find what you were looking for? Find more on ProLog Program to convert decimal number to roman number Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of ProLog Program to convert decimal number to roman number is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!