42pcaeek4 

   
   

Output:

3

Prolog online compiler

Write, Run & Share Prolog code online using OneCompiler’s Prolog online compiler for free. It’s a simple and intuitive platform to experiment with logic programming in Prolog. OneCompiler supports standard Prolog syntax, great for learning, prototyping, and practicing logic-based problems.

About Prolog

Prolog (Programming in Logic) is a logic programming language associated with artificial intelligence and computational linguistics. It works through facts, rules, and queries, using a form of symbolic reasoning known as backward chaining. Prolog is declarative, meaning you describe what you want instead of how to compute it.

Sample Code

The following is a simple Prolog program that prints a greeting:


Syntax Basics

Facts

Facts represent basic assertions about the world.


Rules

Rules define logical relationships using facts.


Queries

Queries are used to find information based on facts and rules.


Operators

OperatorDescription
:-Rule definition
,Logical AND
;Logical OR
=Unification

Lists


Recursion

Prolog heavily relies on recursion.



This guide provides a quick reference to Prolog programming syntax and features. Start writing Prolog code using OneCompiler’s Prolog online compiler today!



© Copyright 2025 One Compiler Pvt. Ltd. | Privacy Policy | Terms & Conditions