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.

26 tháng 3 2021

uses crt;

var i,n,m,k,d:integer;

{---------------chuong-trinh-con-tim-ucln--------------------}

function ucln(x,y:integer):integer;

var t:integer;

begin

while y<>0 do

begin

t:=x mod y;

x:=y;

y:=t;

end;

ucln:=x;

end;

{------------chuong-trinh-con-kiem-tra-so-nguyen-to-------------------}

function nt(b:longint):boolean;

var j:longint;

begin

nt:=true;

if (b=2) or (b=3) then exit;

nt:=false;

if (b=1) or (b mod 2=0) or (b mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(b)) do

begin

if (b mod j=0) or (b mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

{---------------chuong-trinh-chinh---------------------}

begin

clrscr;

write('Nhap N: '); readln(N);

write('Nhap M: '); readln(M);

d:=0;

k:=ucln(N,M);

for i:=1 to k do

if nt(i) then d:=d+1;

if d>0 then writeln('2 so nay tuong duong voi nhau')

else writeln('2 so nay khong tuong duong voi nhau');

readln;

end.

27 tháng 3 2021

lệnh exit dùng để là gì vậy anh?

3 tháng 6 2021

uses crt;

var i,n,m:integer;

a,b:array[1..100]of integer;

function nt(n:integer):boolean;

begin

  if n<2 then nt:=false;

  for i:=2 to n div 2 do

  if n mod i=0 then nt:=false;

end;

function nttd(n,m:integer):boolean;

var i,j,k,d,dem,s:integer;

a,b:array[1..100]of integer;

begin

  nttd:=false;

  d:=0;

  for j:=1 to n do

  if (nt(j))and(n mod j=0) then

  begin

    inc(d);

    a[d]:=j;

  end;

  dem:=0;

  for k:=1 to n do

  if (nt(k))and(m mod k=0) then

  begin

    inc(dem);

    b[dem]:=k;

  end;

  s:=0;

  if d=dem then for i:=1 to d do if a[i]=b[i] then

  inc(s);

  if s=d then nttd:=true else nttd:=false;

end;

BEGIN

  clrscr;

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

  if nttd(n,m) then writeln(n,' va ',m,' la nguyen to tuong duong')

  else writeln(n,' va ',m,' khong phai la nguyen to tuong duong');

  readln;

END.

3 tháng 6 2021

uses crt;

Var M,N,d,i,luun,luum:integer;

Function USCLN(m,n: integer): integer;

Var r: integer;

Begin

luun:=n;luum:=m;

While n<>0 do

begin

r:=m mod n; m:=n; n:=r;

end;

USCLN:=m;

End;

function nttd:integer;

begin

  d:=USCLN(M,N); i:=2;

  While d<>1 do

  begin

    If d mod i =0 then

    begin

      While d mod i=0 do d:=d div i;

      While M mod i=0 do M:=M div i;

      While N mod i=0 do N:=N div i;

    end;

    Inc(i);

  end;

  If M*N=1 then Write(luum,'  va ', luun,' la so nguyen to tuong duong.')

  Else Write(luum ,' va  ',luun ,' khong phai la so nguyen to tuong duong.');

end;

BEGIN

  clrscr;

  Write('Nhap M,N:'); Readln(M,N);

  nttd;

  Readln;

END.

8 tháng 10 2020

Program HOC24;

var i,n,m,k,d: integer;

function ucln(x,y: integer): integer;

var t: integer;

begin

while y<>0 do

begin

t:= x mod y;

x:=y;

y:=t;

end;

ucln:=x;

end;

function nt(b: longint): boolean;

var j: longint;

begin

nt:=true;

if (b=2) or (b=3) then exit;

nt:=false;

if (b=1) or (b mod 2=0) or (b mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(b)) do

begin

if (b mod j=0) or (b mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

write('Nhap N: '); readln(N);

write('Nhap M: '); readln(M);

d:=0;

k:=ucln(N,M);

for i:=1 to k do

if nt(i) then d:=d+1;

if d>0 then write('2 so nay tuong duong voi nhau') else write('2 so nay khong tuong duong voi nhau');

readln

end.

19 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long 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) and (n>1)) cout<<"YES";

else cout<<"NO";

return 0;

}

18 tháng 7 2023

THAM KHẢO!

def is_prime(n):

 if n <= 1:

  return "KHÔNG"# Trường hợp n <= 1 không phải số nguyên tố

 elif n <= 3:

  return "CÓ"# Trường hợp n = 2 hoặc n = 3 là số nguyên tố

 elif n % 2 == 0:

  return "KHÔNG"# Trường hợp n chẵn lớn hơn

 
29 tháng 12 2020

uses crt;

var i,n,s: integer;

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

begin

writeln('Nhap n: '); read(n);

for i:=1 to n do 

begin

write('a[',i,'] = '); readln(a[i]);

end;

writeln('Cac so le: ')

s:=0;

for i:=1 to n do

if a[i] mod 2 <> 0 then 

begin

s:=s+a[i];

write(a[i],' ');

end;

writeln('- Tong so le: ',s);

for i:=1 to trunc(sqrt(s)) do if s mod i = 0 then d:=d+1;

if d > 1 then writeln('Tong do khong la so nguyen to') else writeln('Tong do la so nguyen to');

readln

end.

10 tháng 12 2020

uses crt; var a,b:array[1..100000]of integer;     i,n,kt,j,dem,x,y,kt1:integer;     st,st1:string; begin clrscr; write('Nhap n='); readln(n); for i:=1 to n do   begin      write('A[',i,']='); readln(a[i]);   end; dem:=0; for i:=1 to n do   if a[i]>1 then      begin         kt:=0;         for j:=2 to a[i]-1 do           if a[i] mod j=0 then              begin                 kt:=1;                 break;              end;         if kt=0 then            begin               inc(dem);               b[dem]:=a[i];            end;      end; for i:=1 to dem do   begin      str(a[i],st);      st1:='';      for j:=length(st) downto 1 do        st1:=st1+st[j];      val(st1,x,y);      kt1:=0;      for j:=2 to x-1 do        if x mod j=0 then           begin              kt1:=1;              break;           end;      if kt1=0 then write(a[i]:4);   end; readln; end.

10 tháng 12 2020

uses crt; var a,b:array[1..100000]of integer;     i,n,kt,j,dem,x,y,kt1:integer;     st,st1:string; begin clrscr; write('Nhap n='); readln(n); for i:=1 to n do   begin      write('A[',i,']='); readln(a[i]);   end; dem:=0; for i:=1 to n do   if a[i]>1 then      begin         kt:=0;         for j:=2 to a[i]-1 do           if a[i] mod j=0 then              begin                 kt:=1;                 break;              end;         if kt=0 then            begin               inc(dem);               b[dem]:=a[i];            end;      end; for i:=1 to dem do   begin      str(a[i],st);      st1:='';      for j:=length(st) downto 1 do        st1:=st1+st[j];      val(st1,x,y);      kt1:=0;      for j:=2 to x-1 do        if x mod j=0 then           begin              kt1:=1;              break;           end;      if kt1=0 then write(a[i]:4);   end; readln; end.

10 tháng 4 2021

Program HOC24;

var d,i,n: integer;

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

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

write('Nhap N: '); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

10 tháng 4 2021

uses crt;

var a:array[1..1000]of integer;

i,n,dem,t,j,kt:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

t:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

 if a[i] mod j=0 then kt:=1;

if kt=0 then

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

writeln('Tong cac so nguyen to la: ',t);

readln;

end.

7 tháng 5 2021

uses crt;

const fi='tep.txt';

var f1:text;

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

i,n,kt,j,dem:integer;

begin

clrscr;

assign(f1,fi); reset(f1);

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

readln(f1,a[n]);

end;

dem:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to a[i]-1 do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then inc(dem);

end;

writeln(dem);

close(f1);

readln;

end.