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.

15 tháng 2 2017

uses crt;

var i,n ,dem:integer;

begin

clrscr;

Write( 'nhap so nguyen duong n: ');readln(n);

dem:=0;

for i:=1 to n do if n mod i = 0 then dem:=dem+1;

if(n<2) or (dem< >2) then writeln (n,' khong phai la so nguyen to')

else if dem=2 then writeln(n,' la so nguyen to');

readln

end.

2 tháng 5 2017

program song_to;

uses crt;

var x,i,dem,tcs,t:longint;

function tongchuso(x:longint):longint;

begin

tcs:=0;

while x<>0 do

begin

tcs:=tcs+x mod 10;

x:=x div 10;

end;

tongchuso:=tcs;

end;

begin

clrscr;

write('nhap vao mot so:');readln(x);

dem:=0;

for i:=1 to x do

if x mod i=0 then dem:=dem+1;

if dem=2 then

begin

t:=0;

for i:=1 to tongchuso(x) do

if tongchuso(x) mod i =0 then t:=t+1;

if t=2 then write(x,' la so song to');

end

else write(x,' k la so song to');

readln;

end.banh

23 tháng 2 2023

Bài 1

Var s,i:integer;

tb:real;

Begin

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

i:=1;

s:=0;

While i<=n do

Begin

s:=s+i;

i:=i+1;

End;

tb:=s/n;

Writeln('Tong la ',s);

Write('Trung binh la ',tb:10:2);

Readln;

End.

23 tháng 2 2023

Bài 2

Var i,n,souoc:integer;

Begin

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

i:=1;

While i <= n do

Begin

i:=i + 1;

If n mod i = 0 then souoc:=souoc + 1;

End;

If souoc = 1 then write(n,' la so nguyen to')

Else write(n,' khong la so nguyen to');

Readln;

End.

13 tháng 12 2020

uses crt;

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

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

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln('Tong cua day so la: ',t);

kt:=0;

for j:=2 to trunc(sqrt(t)) do 

  if t mod j=0 then 

    begin

kt:=1;

break;

end;

if kt=0 then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

readln;

end.

13 tháng 12 2020

Cậu ơi sai khúc write('A[',i,']='); readln(a[i]); rồi nó cứ bị sao sao á

 

13 tháng 12 2020

uses crt;

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

i,n,t,kt:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do

t:=t+a[i];

writeln('Tong cac so vua nhap la: ',t);

if t>=2 then 

begin

kt:=0;

for i:=2 to trunc(sqrt(t)) do 

  if t mod i=0 then 

begin

kt:=1;

break;

end;

 if kt=0 then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

end

else writeln(t,' khong la so nguyen to');

readln;

end.

#include <bits/stdc++.h>

using namespace std;

bool kt;

int n,i;

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;

}

 

17 tháng 4 2021

program tim_uoc;

uses crt;

var n,i,j:longint;

begin

clrscr;

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

write('cac uoc cua n la:');

for i:=1 to n do

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

writeln;

j:=0;

for i:=1 to n do

if n mod i=0 then j:=j+1;

if j=2 then writeln(n,' la so nguyen to')

else writeln(n,' khong phai la so nguyen to');

readln;

end.

uses crt;

var n,i,d,dem,kt,t,kt1,t1,t2,t3,max,min,x,j:integer;   

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

st:string;

begin

clrscr;

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

str(n,st);

d:=length(st);

for i:=1 to d do 

val(st[i],a[i],x);

dem:=1;

b[1]:=a[1];

for i:=1 to d do 

begin     

kt:=0;     

for j:=1 to dem do       

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

if kt=0 then       

begin           

inc(dem);           

b[dem]:=a[i];       

end; 

end;

writeln('Cac chu so cua ',n,' la: ');

for i:=1 to dem do 

write(b[i]:4);

writeln;

t:=0;

for i:=1 to d do 

t:=t+a[i];

writeln('Tong cac chu so cua ',n,' la: ',t);

kt1:=0;

for i:=2 to trunc(sqrt(t)) do 

if t mod i=0 then     

begin       

kt1:=1;       

break;     

end;

if (kt1=0) and (t>1) then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

writeln('Cac chu so o vi tri le cua ',n,' la: ');

t1:=0;

for i:=1 to d do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac chu so o vi tri le la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac chu so o vi tri chan cua ',n,' la: ');

t2:=0;

for i:=1 to d do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln('Tong cac chu so o vi tri chan la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if (t3=t2) and (t2>0) then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to d do 

begin     

if max<a[i] then max:=a[i];     

if min>a[i] then min:=a[i]; 

end;

writeln('Chu so lon nhat cua ',n,' la: ',max);

writeln('Chu so nho nhat cua ',n,' la: ',min);

writeln('Tong cua chung la: ',max+min);

readln;

end.

25 tháng 3 2023

Viết rõ ra được ko

hàng 10 là gì vậy

 

29 tháng 3 2023

Uses crt;

var n,i,z: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(n mod i=0) then z:=z+1;

if(z=2) then writeln(z,' la so nguyen to')

else writeln(z,' khong phai la so nguyen to');

readln;

end.

29 tháng 3 2023

program PrimeNumber;

uses crt;

var
  N, i: integer;
  isPrime: boolean;

begin
  clrscr;
  write('Enter N: ');
  readln(N);

  if N <= 1 then
  begin
    writeln('N is not a prime number');
  end
  else
  begin
    isPrime := true;
    for i := 2 to trunc(sqrt(N)) do
    begin
      if N mod i = 0 then
      begin
        isPrime := false;
        break;
      end;
    end;

    if isPrime then
    begin
      writeln('N is a prime number');
    end
    else
    begin
      writeln('N is not a prime number');
    end;
  end;

  readln;
end.

uses crt;

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

i,n,t,t1,t2,t3,min,max:integer;   

kt:boolean;

begin

clrscr;

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

for i:=1 to n do 

begin     

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

end;

writeln('Day so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

t:=t+a[i];

kt:=true;

for i:=2 to trunc(sqrt(t)) do 

if t mod i=0 then     

begin       

kt:=false;       

break;     

end;

writeln('Tong cua day so la: ',t);

if (kt=true) and (t>1) then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

writeln('Cac so o vi tri le cua day so la: ');

t1:=0;

for i:=1 to n do 

if i mod 2=1 then     

begin       

write(a[i]:4);       

t1:=t1+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri le cua day so la: ',t1);

if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')

else writeln(t1,' khong la so chinh phuong');

writeln('Cac so o vi tri chan cua day so la: ');

t2:=0;

for i:=1 to n do 

if i mod 2=0 then     

begin       

write(a[i]:4);       

t2:=t2+a[i];     

end;

writeln;

writeln('Tong cac so o vi tri chan cua day so la: ',t2);

t3:=0;

for i:=1 to t2 do 

if t2 mod i=0 then t3:=t3+i;

if t3=t2 then writeln(t2,' la so hoan hao')

else writeln(t2,' khong la so hoan hao');

max:=a[1];

min:=a[1];

for i:=1 to n do 

begin     

if max<a[i] then max:=a[i];     

if min>a[i] then min:=a[i]; 

end;

writeln('So lon nhat cua day la: ',max);

writeln('So nho nhat cua day la: ',min);

writeln('Tong cua so lon nhat va so nho nhat la: ',max+min);

readln;

end.