K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

D
datcoder
Giáo viên
14 tháng 10 2023

loading...

25 tháng 4 2023

program UocChungLonNhat;
var
  a, b: integer;

function UCLN(a, b: integer): integer;
begin
  if b = 0 then
    UCLN := a
  else
    UCLN := UCLN(b, a mod b);
end;

begin
  write('Nhập số nguyên dương a: ');
  readln(a);
  write('Nhập số nguyên dương b: ');
  readln(b);

  writeln('UCLN của ', a, ' và ', b, ' là ', UCLN(a, b));
end.

15 tháng 3 2022

1 không

2 

 Program UCLN;

uses crt;

var a,b : integer;

begin

write ('nhap so a la ');readln (a);

write ('nhap so b la ');readln (b);

while a < > b do

if a >b then a := a - b else b := b - a ;

write ( ' UCLN la :' , a );

readln

end.

1: 

#include <bits/stdc++.h>

using namespace std;

int n,i;

bool kt;

int main()

{

cin>>n;

kt=true;

for (i=2; i*i<=n; i++)

if (n%i==0) kt=false;

if (kt==true && n>1) cout<<"La so nguyen to";

else cout<<"Khong la so nguyen to";

return 0;

}

13 tháng 12 2020

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.

13 tháng 12 2020

cảm ơn

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à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.

10 tháng 7 2021

var a,b,i,t,s: word;

begin

repeat

writeln('Nhap A,B vao: (cach nhau boi dau Enter)');

readln(a);

read(b);

writeln('Nhap lai gia tri A,B: ');

until (a>=1) and (b>=1) and (a<=10000) and (b<10000);

s:=a+b;

t:=a*b;

if s<t then i:=s else i:=t;

while (s mod i <> 0) or (t mod i <> 0) do i:=i-1;

writeln('UCLN cua A+B va AB: ',i);

writeln('So du khi chia AB cho A+B: ', t mod s);

end.

#include <bits/stdc++.h>

using namespace std;

long long a,b;

//chuongtrinhcon

long long ucln(long long a,long long b)

{

if (b==0) return(a);

else return(ucln(b,a%b));

}

//chuongtrinhchinh

int main()

{

cin>>a>>b;

cout<<ucln(a,b);

return 0;

}

for i:=1 to n do 

  if n mod i=0 then write(i:4);

Chương trình đầy đủ:

uses crt;

var n,i:integer;

begin

clrscr;

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

for i:=1 to n do 

  if n mod i=0 then write(i:4);

readln;

end.

#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;
}