1. Home
  2. /
  3. Mercury
  4. /
  5. Multiplication Table

Multiplication Table - Mercury Typing CST Test

Loading…

Multiplication Table — Mercury Code

Prints multiplication table for a number.

:- module multable.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.

:- implementation.

main(!IO) :-
	N = 5,
	for I = 1 to 10 do
		io.write_int(N, !IO), io.write_string(" x ", !IO), io.write_int(I, !IO), io.write_string(" = ", !IO), io.write_int(N*I, !IO), io.write_string("\n", !IO).

Mercury Language Guide

Mercury is a purely declarative logic programming language with strong typing, determinism analysis, and a focus on reliability and performance. It is designed for building large-scale, maintainable, and efficient logic programs while avoiding common pitfalls of traditional Prolog systems.

Primary Use Cases

  • ▸Logic-based and symbolic programming
  • ▸Constraint solving
  • ▸Knowledge representation
  • ▸Formal verification and theorem proving
  • ▸Academic research and teaching

Notable Features

  • ▸Purely declarative semantics
  • ▸Strong, static type system
  • ▸Mode and determinism checking
  • ▸High-performance compiler
  • ▸Separation of logic and control flow

Origin & Creator

Mercury was created in the mid-1990s by Zoltan Somogyi, Fergus Henderson, and Thomas Conway at the University of Melbourne, building on ideas from Prolog but with stricter type and mode systems.

Industrial Note

Mercury is used in academic research, formal verification, symbolic computation, and complex rule-based systems. While not mainstream, it is highly valued in areas requiring highly reliable logic programs.

More Mercury Typing Exercises

Mercury Counter and Theme ToggleMercury Fibonacci SequenceMercury Factorial CalculatorMercury Prime CheckerMercury Sum of ListMercury Reverse StringMercury Celsius to FahrenheitMercury Simple Alarm SimulationMercury Random Walk Simulation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher