File:GCD through successive subtractions.svg
![File:GCD through successive subtractions.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/GCD_through_successive_subtractions.svg/480px-GCD_through_successive_subtractions.svg.png?20240426131243)
Original file (SVG file, nominally 660 × 825 pixels, file size: 5 KB)
Captions
Captions
Summary
[edit]DescriptionGCD through successive subtractions.svg |
English: The set of common divisors of two given natural numbers is the set of divisors of one and only one natural number, called the “greatest common divisor” of the initial pair. To prove its existence, it is sufficient to exhibit we can always calculate it, from any pair of natural numbers. How to understand “greatest”? The order in question is divisibility: a partial order on set ℕ of natural numbers. For example, 2 is a common divisor
Under the algorithm of the image, Instead of replacing A novice in coding can copy and paste in a window dedicated to JavaScript one of the following comparisons, and then command the execution: /* To open a Firefox window
dedicated to JavaScript code: Shift + F4 */
d = r = k = 182; p = 238; // example of input values,
// that we can replace with two other natural numbers
if( s = p){ // if the common value of s and p is not zero
while(r){ // while the value of r is not zero
if(r < s){ // in this case, reverse the values of r and s
d = s; s = r; r = d }
r = r-s } // end of the loop 'while(r)'
d = s } // end of the block that begins with 'if( s = p)'
" GCD("+ k +", "+ p +") = "+ d; // output: a String object
// Keyboard shortcut in Firefox to execute the code: Ctrl + L
On the image top, try{ // in case of error in this block,
// execution failure of this code block, go to 'catch'
d = r = k = 408; p = 255; // example of input values
var b; // global scope declaration
s = function(n){
// to test the value of parameter n: is it a natural number?
b = n.constructor == Number; // Boolean value
if( !b // first incorrect case
|| n < 0 || n != Math.floor(n) // other incorrect cases
) throw n
// in one of the previous cases, n is thrown as error
}; // end of assignment to variable s
s(k); s(p); // verifications
if( s = p){ // if the common value of s and p is not zero
while(r){
if(r < s){d = s; s = r; r = d} r = r-s } d = s }
" GCD("+ k +", "+ p +") = "+ d
}catch(e){ // in case of error (if e is thrown)
" "+( b ? e +" is not a natural number.":
" Incorrect code.")
}
Français : Voir la version en français… |
Date | |
Source | Own work |
Author | Arthur Baelde |
Other versions | |
SVG development InfoField | ![]() This /Baelde was created with a text editor. |
Licensing
[edit]![w:en:Creative Commons](https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/CC_some_rights_reserved.svg/90px-CC_some_rights_reserved.svg.png)
![attribution](https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/Cc-by_new_white.svg/24px-Cc-by_new_white.svg.png)
![share alike](https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Cc-sa_white.svg/24px-Cc-sa_white.svg.png)
- 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.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 13:12, 26 April 2024 | ![]() | 660 × 825 (5 KB) | Arthur Baelde (talk | contribs) | more legible |
09:06, 27 June 2018 | ![]() | 660 × 825 (5 KB) | Arthur Baelde (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following 5 pages use this file:
File usage on other wikis
The following other wikis use this file:
- Usage on bo.wikipedia.org
- Usage on en.wikipedia.org
- Usage on jv.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 660 |
---|---|
Height | 825 |