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.

29 tháng 7 2022

Program shh;

Uses crt;

Var n,t,i:integer;

Begin

      clrscr;

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

      t:=0;

for i:=1 to n-1 do

if n mod i=0 then t:=t+i;

if t=n then writeln(n,' la so hoan hao')

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

readln;

End.

1 tháng 8 2022

function shc(n:longint):boolean;

var i,s:longint;

begin

s := 0;

for i := 1 to n div 2 do

begin

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

end;

if s = n then shc:=true else

shc:=false;

end;

7 tháng 7 2023

program bai_toan;

var

      N, i, sum: integer;

begin

      write('Nhap so N: ');

      readln(N);

      write('Cac uoc cua ', N, ' khong ke ', N, ' la: ');

      for i := 1 to N - 1 do

            if N mod i = 0 then

                  write(i, ' ');

      writeln;

      sum := 0;

      for i := 1 to N - 1 do

      begin

            if N mod i = 0 then sum := sum + i;

      end;

      if sum = N then writeln(N, ' la so hoan hao')

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

      writeln;

      writeln('Tat ca so hoan hao trong pham vi 1 -> ', N, ' la:');

      for i := 1 to N do

      begin

            sum := 0;

            for j := 1 to i - 1 do

            begin

                  if i mod j = 0 then sum := sum + j;

            end;

            if sum = i then writeln(i);

      end;

      readln;

end.

2:

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,i,kt=0;

cin>>n;

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

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

if (kt==0) cout<<"YES";

else cout<<"NO";

}

c: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++)

if (a[i]%2==0) cout<<a[i]<<" ";

return 0;

}

d: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,nn;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn;

return 0;

}

uses crt;

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

i,n,j:integer;

kt:boolean;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do 

 if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);

writeln;

for i:=1 to n do 

 if a[i]>1 then 

begin

kt:=true;

for j:=2 to trunc(sqrt(a[i])) do

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

if kt=true then write(a[i]:4);

end;

writeln;

readln;

end.

29 tháng 3 2022

Var i,n,dem:integer;

begin

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

for i:=1 to n do

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

if dem=2 then write(n,' la so nguyen to')

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

readln;

end.

20 tháng 3 2023

program SoHoanHao;

uses crt;

var

     i, j, n, s: integer;

begin

     clrscr;

     write('Nhap n: ');

     readln(n);

     for i := 1 to n do

     begin

          s := 0;

          for j := 1 to i - 1 do

          begin

               if i mod j = 0 then

                    s := s + j;

               end;

               if s = i then

                    writeln(i);

     end;

     readln;

end.