Những câu hỏi liên quan
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 12 2020 lúc 17:09

uses crt;

var a,b,ucln,bcnn,i:integer;

begin

clrscr;

write('Nhap a='); readln(a);

write('Nhap b='); readln(b);

ucln:=1;

if a<b then begin

                        for i:=1 to a do

                           if (a mod i=0) and (b mod i=0) then                                             begin

                                     if ucln<i then ucln:=i;            

                               end;    

                   end else begin

              for i:=1 to b do

                  if (a mod i=0) and (b mod i=0) then

                      begin

                           if ucln<i then ucln:=i;

                      end;      

       end;

bcnn:=a*b;

for i:=a*b-1 downto 1 do  

   if (i mod a=0) and (i mod b=0) then      

       begin

             if bcnn>i then bcnn:=i;      

       end;

writeln('Uoc chung lon nhat la: ',ucln); 

writeln('Boi chung nho nhat la: ',bcnn);

readln;

end.

Bình luận (1)
Vũ Kiệt
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 22:26

Câu 1: 

uses crt;

var m,n,ucln,i:integer;

begin

clrscr;

write('Nhap m='); readln(m);

write('Nhap n='); readln(n);

ucln:=1;

if m<n then 

begin

for i:=1 to m do 

if (m mod i=0) and (n mod i=0) then 

  begin

if ucln<i then ucln:=i;

end;

end

else begin

for i:=1 to n do 

  if (m mod i=0) and (n mod i=0) then 

begin

if ucln<i then ucln:=i;

end;

end;

writeln(ucln);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 22:27

Câu 2: 

uses crt;

var m,n,bcnn,i:integer;

begin

clrscr;

write('Nhap m='); readln(m);

write('Nhap n='); readln(n);

bcnn:=m*n;

for i:=m*n-1 downto 1 do 

  if (i mod m=0) and (i mod n=0) then

begin

if bcnn>i then bcnn:=i;

end;

writeln(bcnn);

readln;

end.

Bình luận (0)
Vũ Quang Vinh
31 tháng 8 2021 lúc 15:48

BCNN:

program boichung;
var m,n: word;

procedure Input;
        begin
            readln(m,n);
        end;

function BC(m,n: word): word;
var i: word;
       begin
           for i := 1 to n * m do
               if (i mod n = 0) and (i mod m = 0) then
                   write(i,' ');
       end;

begin
    Input;
    BC(m,n);
end.

UCLN:

program UCLN;
var m,n,r,i: longint;
begin
readln(n,m);

n := abs(n);
m := abs(m);

if (n = 0) then
    begin
        i := 1;
        write(m);
    end
else
    if (m = 0) then
        begin
            i := 1;
            write(n);
        end;

r := n mod m;
while r <> 0 do
      begin
        r := n mod m;
        n:= m;
        m:= r;
      end;
if (i = 0) then
    write(n);

readln    
end.

Bình luận (0)
Yến Nhi
Xem chi tiết
phamthiminhanh
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 20:42

Bài 1:

uses crt;

var n,i,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

s:=0;

for i:=1 to n do 

 if i mod 6=0 then s:=s+i;

writeln(s);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 20:46

Bài 2: 

uses crt;

var a,b,c,ucln,i:integer;

begin

clrscr;

write('a='); readln(a);

write('b='); readln(b);

write('c='); readln(c);

while a<>b do 

  begin

if a>b then a:=a-b

else b:=b-a;

end;

ucln:=a;

while ucln<>c do 

 begin

if ucln>c then ucln:=ucln-c

else c:=c-ucln;

end;

writeln(ucln);

readln;

end.

Bình luận (0)
Yoriichi_Tsugikuni ( ɻɛɑ...
11 tháng 6 2021 lúc 14:55

Scratch hay java

Bình luận (0)
 Khách vãng lai đã xóa
Hiền Nguyễn
Xem chi tiết
nguyễn an phát
27 tháng 5 2021 lúc 14:24

a)

program UCLN_va_BCNN;

uses crt;

var a,b,c,r,p:integer;

begin

clrscr;

write('nhap a,b:');readln(a,b);

if a<b then 

begin

c:=a;

a:=b;

b:=c;

end;

p:=a*b;

r:=a mod b;

while r<>0 do

begin

a:=b;

b:=r;

r:=a mod b;

end;

writeln('UCLN la: ',b);

writeln('BCNN la: ',p div b);

readln;

end.

Bình luận (0)
nguyễn an phát
27 tháng 5 2021 lúc 14:30

b)

program fibonaci;

uses crt;

var i,n:integer;

a:array[1..30]of integer;

begin

clrscr;

repeat

write('nhap n:');readln(n);

if (n<1)or(n>30) then writeln('so n phai lon hon hoac bang 1 va nho hon hoac bang 30:);

until (n>=1)and(n<=30);

a[1]:=1;

a[2]:=1;

for i:=3 to n do

a[i]:=a[i-1]+a[i-2];

writeln(n,' so fibonaci dau tien la:');

for i:=1 to n do

write(a[i]:3);

readln;

end.

Bình luận (0)
Bùi Duy Vương
Xem chi tiết
OoO Hoàng Tử Lạnh Lùng O...
1 tháng 6 2016 lúc 16:19

câu trả lời là mới hok lp 5 sang năm lên lp 6 :)

Bình luận (0)
Nguyễn Tuấn Minh
1 tháng 6 2016 lúc 16:26

Gọi 2 số đó là a và b, ƯCLN(a,b)=d

=>a=da'

   b=db'

(a',b')=1

BCNN(a,b)=da'b'

Tổng ƯCLN và BCNN là d+da'b'=d(a'b'+1)=126

126 phân tích ra thừa số nguyên tố là 2.32.7

Do đó d=2 hoặc a'b'+1=2

Nếu d=2 thì a'b'+1=126:2=63

a'b'=62. Giả sử a>b thì a'>b'

TH1: a'=31, b'=2 =>a=31.2=62, b=2.2=4. a-b=58

TH2 a'=62, b'=1 =>a=62.2=124, b=2. a-b=122.

Hiệu nhỏ nhất nếu d=2 là 58

Tiếp theo ta xét

a'b'+1=2

a'b=1

=>a'=b'=1

Khi đó d=126:2=63

Ta có a=63, b=63

a-b=0

Tuy nhiên đề bài yêu cầu tìm hiệu dương mà số 0 ko dương cũng ko âm

Vậy 2 số cần tìm là 62 và 4

Bình luận (0)
Nguyễn Tuấn Minh
1 tháng 6 2016 lúc 16:32

Hình như mình làm sai. Đợi mình nghĩ lại nha

Bình luận (0)
Hello1234
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 9 2021 lúc 2:03

#include <iostream>
using namespace std;
int main()
{
    int t,m,n,ucln;
    cout<<"Nhap n="; cin>>n;
    cout<<"Nhap m="; cin>>m;
    t=m%n;
    while (t!=0)
    {
        t=n%m;
        n=m;
        m=t;
    }
    ucln=n;
    cout<<ucln;
    return 0;
}

 

Bình luận (0)
Minh Lệ
Xem chi tiết
Nguyễn Quốc Đạt
14 tháng 10 2023 lúc 21:47

loading...

Bình luận (0)
Mai Xuân Phúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:51

#include <bits/stdc++.h>

using namespace std;

long long m,n;

//chuongtrinhcon

long long ucln(long long m,long long n)

{

if (n==0) return(m);

else return(ucln(n,m%n));

}

//chuongtrinhchinh

int main()

{

cin>>n>>m;

cout<<ucln(n,m);

return 0;

}

Bình luận (0)
Mai Xuân Phúc
4 tháng 4 2022 lúc 22:02

Pascal bạn ơi

Bình luận (0)