.. index:: single: natural
.. _natural/0:

.. rst-class:: right

**object**

``natural``
===========

Natural numbers data type predicates.

| **Availability:** 
|    ``logtalk_load(types(loader))``

| **Author:** Paulo Moura
| **Version:** 2:0:0
| **Date:** 2026-02-02

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Extends:**
|    ``public`` :ref:`integer <integer/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`comparingp/0::(<)/2`  :ref:`comparingp/0::(=:=)/2`  :ref:`comparingp/0::(=<)/2`  :ref:`comparingp/0::(=\=)/2`  :ref:`number/0::=~= / 2`  :ref:`comparingp/0::(>)/2`  :ref:`comparingp/0::(>=)/2`  :ref:`number/0::approximately_equal/2`  :ref:`number/0::approximately_equal/3`  :ref:`integer/0::between/3`  :ref:`termp/0::check/1`  :ref:`termp/0::depth/2`  :ref:`number/0::essentially_equal/3`  :ref:`termp/0::ground/1`  :ref:`termp/0::new/1`  :ref:`termp/0::numbervars/1`  :ref:`termp/0::numbervars/3`  :ref:`termp/0::occurs/2`  :ref:`integer/0::plus/3`  :ref:`integer/0::power_sequence/4`  :ref:`integer/0::sequence/3`  :ref:`integer/0::sequence/4`  :ref:`termp/0::singletons/2`  :ref:`termp/0::subsumes/2`  :ref:`termp/0::subterm/2`  :ref:`integer/0::succ/2`  :ref:`number/0::tolerance_equal/4`  :ref:`termp/0::valid/1`  :ref:`termp/0::variables/2`  :ref:`termp/0::variant/2`  :ref:`termp/0::varnumbers/2`  :ref:`termp/0::varnumbers/3`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: factorial/2
.. _natural/0::factorial/2:

``factorial/2``
^^^^^^^^^^^^^^^

Computes the factorial of a non-negative integer.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``factorial(N,Factorial)``
| **Mode and number of proofs:**
|    ``factorial(+non_negative_integer,-non_negative_integer)`` - ``one``


------------

.. index:: binomial/3
.. _natural/0::binomial/3:

``binomial/3``
^^^^^^^^^^^^^^

Computes the binomial coefficient. ``N`` must be greater than or equal to ``K`` (fails otherwise).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``binomial(N,K,Binomial)``
| **Mode and number of proofs:**
|    ``binomial(+non_negative_integer,+non_negative_integer,-non_negative_integer)`` - ``zero_or_one``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

