File:Iterated subtraction of d until modulo d.svg
Summary
| Description |
Français : See File:Itérer une soustraction de d jusque modulo d.svg 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 |
Licensing
Arthur Baelde, the copyright holder of this work, hereby publishes it under the following license:
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.