mod ( n1 n2 -- n3 )
published: 9 January 2022 / updated 16 February 2022
vocabulary: forth
Divide n1 by n2, giving the single-cell remainder n3.
The modulo function can be used to determine the divisibility of one number by another.
Example:
21 7 mod . \ display 0 22 7 mod . \ display 1 23 7 mod . \ display 2 24 7 mod . \ display 3 : DIV? ( n1 n2 ---) OVER OVER MOD CR IF SWAP . ." is not " ELSE SWAP . ." is " THEN ." divisible by " . ;
Legal: site web personnel sans commerce / personal site without seling
