파일:GCD through successive subtractions.svg

testwiki
둘러보기로 이동 검색으로 이동
    원본 파일 (SVG 파일, 실제 크기 660 × 825 픽셀, 파일 크기: 5 KB)

    이 파일은 위키미디어 공용에 있으며, 다른 프로젝트에서 사용하고 있을 가능성이 있습니다. 해당 파일에 대한 설명이 아래에 나와 있습니다.

    파일 설명

    설명
    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 of {30, 24}, that can be written: 2|30 and 2|24. We will soon calculate the greatest common divisor of {30, 24}: GCD(30, 24)=6. Zero is multiple of any natural number, in other words, zero is the greatest element of ℕ for divisibility. And GCD(0, 0)=0  is not the greatest natural number for the usual order relation, of which the symbol is ⩽. The least element of ℕ for divisibility is 1.

    Denoting by C the set of common divisors of {30, 24}, 30 and 24 are multiples of any element dof C. Therefore 30−24=6 is also a multiple of d. Conversely, every common divisor of {24, 6} is also a divisor of 24 and 6+24=30. In other words, C is also the set of common divisors of {24, 6}.

    Under the algorithm of the image, {30, 24} is replaced with {24, 6}, and then by repeating the process replaced with {18, 6}, because 24−6=18. And then replaced with {12, 6}, and with {6, 6}. Finally the step‑by‑step process replaces the initial pair with {6, 0}, goes out of the loop of subtractions, and affirms: 6 is the GCD of 30 and 24.

    Instead of replacing {24, 6} with the four successive pairs: {18, 6}, {12, 6}, {6, 6}, {0, 6}, we could get directly the last pair by the Euclidean division of 24 by 6. It does not matter there are 4 successive subtractions of 6, we can ignore 4: the quotient value of this Euclidean division. Actually, every sequence of subtractions of a same number can be replaced with an Euclidean division by this number. Thus we discover the more known algorithm of GCD through successive Euclidean divisions, by improving the present algorithm of subtractions.

    A novice in coding can copy and paste in a window dedicated to JavaScript one of the following comparisons, and then command the execution: 30 < 24; or 6 == 0; or 6 < 24. Within the image, six symbols look like assignments in OCaml. Here is an example of assignment in JavaScript: r = 30; commanding to store into variable r the object of type Number and value 30. Everyone can download Firefox, and then open a Firefox window dedicated to JavaScript code. In this special window, we can copy and paste the following translation from the flow chart into JavaScript.

    /* 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,  r∈ℕ  means that  r is a in  set ℕ of natural numbers. The previous JavaScript code works only if the two input values are natural numbers. Here is an improvement of the previous code, where the input values assigned to k and p are verified.

    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.")
    }
    
    The GCD operation is classically used to simplify a fraction. For example, GCD(408, 255)=51, 40851=8  and  25551=5, so 85 is the irreducible form of 408255. Two natural numbers of which the GCD is 1 are called coprime integers.
     
    Français : Voir la version en français…
    날짜
    출처 자작
    저자 Arthur Baelde
    다른 버전
    SVG 발전
    InfoField
     이 SVG 파일의 소스 코드 문법이 올바릅니다.
     이 /Baelde 문서 편집기(으)로 제작되었습니다.

    라이선스

    Arthur Baelde은(는) 아래 작품의 저작권자로서, 해당 저작물을 다음과 같은 라이선스로 배포합니다:
    w:ko:크리에이티브 커먼즈
    저작자표시 동일조건변경허락
    저작자표시:
    이용자는 다음의 권리를 갖습니다:
    • 공유 및 이용 – 저작물의 복제, 배포, 전시, 공연 및 공중송신
    • 개작 – 저작물의 개작, 수정, 2차적저작물 창작
    다음과 같은 조건을 따라야 합니다:
    • 저작자표시 – 적절한 저작자 표시를 제공하고, 라이선스에 대한 링크를 제공하고, 변경사항이 있는지를 표시해야 합니다. 당신은 합리적인 방식으로 표시할 수 있지만, 어떤 방식으로든 사용권 허가자가 당신 또는 당신의 사용을 지지하는 방식으로 표시할 수 없습니다.
    • 동일조건변경허락 – 만약 당신이 이 저작물을 개작 또는 변형하거나 이 저작물을 기반으로 제작하는 경우, 당신은 당신의 기여물을 원저작물과 동일하거나 호환 가능한 라이선스에 따라 배포하여야 합니다.

    설명

    이 파일이 나타내는 바에 대한 한 줄 설명을 추가합니다
    The algorith transforms any pair of positive integers into another having the same common divisors, and including a decisive 0,  through a process able to interchange two integers, or remplace the greatest with the positive difference of the two

    이 파일에 묘사된 항목

    다음을 묘사함

    825 화소

    660 화소

    image/svg+xml

    5,170 바이트

    21aa7924f6efff251b49270eeb556c464e628f72

    파일 역사

    날짜/시간 링크를 클릭하면 해당 시간의 파일을 볼 수 있습니다.

    날짜/시간섬네일크기사용자설명
    현재2025년 2월 9일 (일) 13:182025년 2월 9일 (일) 13:18 판의 섬네일660 × 825 (5 KB)wikimediacommons>Arthur Baelde the  latest  version  is  the  best  one 

    이 파일을 사용하는 문서가 없습니다.