ĐA LTHT - BÀI TẬP 1

Embed Size (px)

Citation preview

  • 8/3/2019 A LTHT - BI TP 1

    1/3

    16. Vit chng trnh tnh c s chung ln nht ca 2 s a v b! Vi a, b l s nguyndng nhp t bn phm. In kt qu ra mn hnh dng thp phn.

    c s chung ln nht

    Trong ton hc, nu s nguyn achia ht cho s nguyn dth s dc gi lc ca s nguyn a, a c gi l bi ca d. S nguyn dng dln nht lc ca c hai s nguyn a, b c gi l c chung ln nht (CLN) ca a vb. Trong trng hp c hai s nguyn a v b u bng 0 th chng khng cCLN v khi mi s t nhin khc khng u l c chung ca a v b. Nuch mt trong hai s a hoc b bng 0, s kia khc khng th CLN ca chngbng gi tr tuyt i ca s khc khng.

    K hiu v v d

    c chung ln nht ca a v b c k hiu l CLN(a, b), hay n ginhn l (a, b). Chng hn, CLN(12, 18) = 6, CLN(4, 14) = 2 andCLN(5, 0) = 5. Hai s c gi lnguyn t cng nhau nu c chung lnnht ca chng bng 1. Chng hn, 9 v 28 l nguyn t cng nhau.

    c chung ln nht c s dng a mt phn s v dngphn sti gin. Chng hn, CLN(42, 56)=14, do ,

    Tnh c chung ln nht

    CLN ca hai s c th tm c bng vic phn tch hai s ra tha snguyn t, chng hn tm CLN(18,84), ta phn tch 18 = 232 v 84 =2237 v nhn xt rng cc tha s chung ln nht ca hai s ny l 23;do CLN(18,84) = 6. Trn thc t phng php ny ch dng cho ccs nh; vic phn tch cc s ln ra tha s nguyn t mt rt nhiu thigian.

    http://vi.wikipedia.org/wiki/To%C3%A1n_h%E1%BB%8Dchttp://vi.wikipedia.org/w/index.php?title=Chia_h%E1%BA%BFt_cho&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Chia_h%E1%BA%BFt_cho&action=edit&redlink=1http://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAnhttp://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAn_t%E1%BB%91_c%C3%B9ng_nhauhttp://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/wiki/To%C3%A1n_h%E1%BB%8Dchttp://vi.wikipedia.org/w/index.php?title=Chia_h%E1%BA%BFt_cho&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Chia_h%E1%BA%BFt_cho&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Chia_h%E1%BA%BFt_cho&action=edit&redlink=1http://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAnhttp://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAnhttp://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAn_t%E1%BB%91_c%C3%B9ng_nhauhttp://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAn_t%E1%BB%91_c%C3%B9ng_nhauhttp://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAn_t%E1%BB%91_c%C3%B9ng_nhauhttp://vi.wikipedia.org/wiki/S%E1%BB%91_nguy%C3%AAn_t%E1%BB%91_c%C3%B9ng_nhauhttp://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/w/index.php?title=Ph%C3%A2n_s%E1%BB%91_t%E1%BB%91i_gi%E1%BA%A3n&action=edit&redlink=1http://vi.wikipedia.org/wiki/To%C3%A1n_h%E1%BB%8Dc
  • 8/3/2019 A LTHT - BI TP 1

    2/3

    Tm c s chung ln nht ca 2 s nguyn dng*Gii thut:Input: u vo l 2 s nguyn dng m,nOutput: c s chung ca m,n: USCLN

    while (n!=m){

    if (n>m)n=n-m;

    else m=m-n;}

    USCLN=n;

    * C++#include

    #include

    void main()

    {int a,b,uscln;

    printf("\n Tim USCLN cua a va b");

    printf("\n Moi ban nhap 2 so a va b:");

    scanf("%d%d",&a,&b);

    while (a!=b)/* Khi a # b */

    {if (a

  • 8/3/2019 A LTHT - BI TP 1

    3/3

    WHILE_:CMP AX,BXJE THOAT_JG NHAN_1

    SUB BX,AXJMP WHILE_

    NHAN_1:SUB AX,BXJMP WHILE_

    THOAT_:

    c s chug ln nht lu AX

    http ://www .programmingforums .org /thread 1990.html

    http ://rosettacode .org /wiki/Greatest_ common_ divisor # x 86_ Assembly

    http ://www .syntax -example .com /Code /find -greatest-common -divisor -gcd -two -548.aspx

    http://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://www.programmingforums.org/thread1990.htmlhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://rosettacode.org/wiki/Greatest_common_divisor#x86_Assemblyhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspxhttp://www.syntax-example.com/Code/find-greatest-common-divisor-gcd-two-548.aspx