File:Iterated subtraction of d until modulo d.svg

Summary

Description
English: Through an iterated subtraction of d from n as long as the difference is positive,  calculation of the remainder of the Euclidean division of n by d,  called n modulo d.

Translation  in  JavaScript.

/*  To open  a  Firefox  window
 dedicated to JavaScript code:   Shift + F4   */

 r = n = 72;  d = 20;
/*  Initial pair of positive integers:   the dividend
    and the divisor of the Euclidean division.   The two variables
    n  and  r  have the same initial value,   because the instruction
    n = 72   returns  72  (of type Number).   And   n.toString(10)
    would return the dividend writing in decimal numeral system
    (of base 10).
*/

 n = " " + n +" modulo "+ d +" = ";
/*  The initial pair is stored in  n  as object  String.
 The space as first character of the string is of type  String.
 So the first sign  +  is a symbol of concatenation of strings
 of characters.   Variable  n  that follows is implicitly
 converted in   n.toString(10) :    one or several digits
 that come after the first space,  and before another space.
*/

 while( r >= d) r -= d;
/*  Loop :  calculation of the remainder of the division.
 With   r >= d   equivalent to   ! (r < d)   (the contrary of   r < d),
 and    r -= d   equivalent to   r = r-d
*/

 n + r ;
/*  Result of type  String,   where the decimal writing of remainder  r
   of the division comes after the previous value of  n.


 Keyboard shortcut in Firefox to execute the code:   Ctrl + L   */
Date
Source Own work
Author Arthur Baelde
SVG development
InfoField
 The SVG code is valid.
Category:Valid SVG created with Text Editor/Baelde
 This /Baelde was created with a text editor.

Licensing

Arthur Baelde, the copyright holder of this work, hereby publishes it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
Attribution:
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Iterated%20subtraction%20of%20d%20until%20modulo%20d.svgCategory:Self-published work
Category:SVG flow charts Category:Modular arithmetic
Category:CC-BY-SA-4.0 Category:Modular arithmetic Category:SVG flow charts Category:Self-published work Category:Valid SVG created with Text Editor/Baelde