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.

uses crt;

var n,i,t,j:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

  begin

t:=0;

for j:=1 to i div 2 do 

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

if t=i then write(i:4);

end;

readln;

end.

22 tháng 7 2023

program so_hoan_hao;

var

       n, tong_uoc, i: integer;

begin

       writeln('Nhap vao mot so nguyen duong n:');

       readln(n);

       tong_uoc := 0;

       for i := 1 to n-1 do

       begin

              if n mod i = 0 then

                     tong_uoc := tong_uoc + i;

       end;

       if tong_uoc = n then

              writeln('YES')

       else

              writeln('NO');

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.

7 tháng 12 2021

TK

https://www.google.com/url?sa=t&source=web&rct=j&url=https://freetuts.net/thuat-toan-kiem-tra-so-hoan-hao-2919.html&ved=2ahUKEwih6ejz18_0AhVPslYBHVhcBmIQFnoECD8QAQ&usg=AOvVaw0Mb94AOV2KpQWjxBRg9BYD

1 tháng 2 2021

Cho biến i chạy từ 1 đến n. Xét i. Nếu nó là số hoàn chỉnh thì in ra.

Program Tim_uoc_2;

uses crt;

Var S, n, i,j: longint;

Begin

clrscr;

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

For i:=1 to n do

Begin

S:=0;

For j:=1 to i do if i mod j = 0 then S:=S+j;

if S = 2*i then write(i:6,',');

end;

readln

end.

uses crt;

var n,i,t,j:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

t:=0;

for j:=1 to i do 

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

if t=i then write(i:4);

end;

readln;

end.

8 tháng 1 2019

Ở đây mình sẽ làm VD của 1 ước 6 nha

var n: integer ;

begin

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

if n mod 6=0 then write('n la so ban hoan hao') else ('n khong phai la mot so ban hoan hao');

readln

end.

8 tháng 1 2019

mik biết viết rồi nhưng k phải của bạn viết bạn viết thế k dc

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";

}

17 tháng 2 2022

{PROGRAM bai_tap;
USES crt ;
VAR i , n, t:integer;
BEGIN  
  clrscr;
  Write('Nhap 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 write(n,' la so hoan chinh');
  else Writeln(n,' Khong la so hoan chinh');
  Readlnnline Pascal Compiler.
begin    
  End,
Readlnnline
END.

}

#include <bits/stdc++.h>

using namespace std;

long long n,i,t;

int main()

{

cin>>n;

t=0;

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

if (n%i==0) t=t+i;

if (t==n) cout<<"YES";

else cout<<"NO";

return 0;

}

uses crt;

var n,i,t:integer;

begin

clrscr;

write('Nhap 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 chinh')

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

readln;

end.

6 tháng 11 2021

program hoan_chinh;

uses crt;

var n,i,s:integer;

begin

clrscr;

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

for i:=1 to n-1 do

 begin

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

 end;

if s=n then writeln('1') {n là số chính phương thì viết 1}

else writeln('0');{n không là số chính phương thì viết 0}

end.

uses crt;

var i,j,t:integer;

begin

clrscr;

for i:=1 to 99 do 

  begin

t:=0;

for j:=1 to i-1 do 

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

if t=i then write(i:4);

end;

readln;

end.