program sohoanhao;
uses crt;
var i,j, tong: integer;
begin
clrscr;
for i:=1 to 100 do
begin
tong:=0;
for j:= i-1 downto 1 do
if i mod j = 0 then tong:= tong + j;
if tong = i then write(i,',');
end;
readln
end.
xin lỗi chương trình trước thiếu số 1 nên mình bổ sung:
program sohoanhao;
uses crt;
var i,j,tong: integer;
begin
clrscr;
write('1,');
for i:= 1 to 100 do
begin
tong:=0;
for j:=i-1 downto 1 do
if i mod j = 0 then tong:=tong+j;
if tong = i then write(i,',');
end;
readln
End.
Var S,i,d:LONGINT;
Begin
clrscr;
For i:=1 to 100 do
Begin
S:=0;
For d:=1 to i do
if i mod d = 0 then
S:=S+d;
if S =2 *i then
write(i:6);
end;
readln;
end.
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/ package test01;
import java.io.BufferedReader
; import java.io.IOException
; import java.io.InputStreamReader
* @author DOTNETGROUP
*/ public class Test01
* @param args the command line arguments
*/ public static void main(String[] args) throws IOException{
// TODO code application logic here
BufferedReader kbd = new BufferedReader(new InputStreamReader(System.in));
//System.out.print("Nhap a: ");
//String s=kbd.readLine();
//int a=Integer.parseInt(s);
System.out.print("Nhap n: ");
String s=kbd.readLine();
int b=Integer.parseInt(s);
for(int i = 1;i<b;i++)
{ int tong=0; for(int j=1; j<i;j++)
{ if(i%j==0) tong+=j;
if(i==tong)
{ System.out.println(i); } } } }
Program So_hoan_hao;
Uses crt;
Var S, i ,j : integer;
Begin
clrscr;
For i:=1 to 100 do
begin
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.
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package test01; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author DOTNETGROUP */ public class Test01 { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException{ // TODO code application logic here BufferedReader kbd = new BufferedReader(new InputStreamReader(System.in)); //System.out.print("Nhap a: "); //String s=kbd.readLine(); //int a=Integer.parseInt(s); System.out.print("Nhap n: "); String s=kbd.readLine(); int b=Integer.parseInt(s); for(int i = 1;i<b;i++) { int tong=0; for(int j=1; j<i;j++) { if(i%j==0) tong+=j; } if(i==tong) { System.out.println(i); } } } }
program hoc24hoc24;
uses crt;
var i,j,S: integer;
BEGIN
clrscr; S:= 0;
write ('cac so hoan hao nho hon 100 la: ');
for i:= 1 to 100 do
begin
for j:= 1 to i-1 do if i mod j = 0 then S:= S+j;
if i=S then writeln (i);
end;
READLN
END.
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,
74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
97,98,99,100
xong từ 1 đến 100 như yêu cầu
Program viet_chuong_trinh_tinh_tong;
Uses Crt;
Var i,s:integer;
Begin
Clrscr;
i:=2;
While (i>1) and (i<=100) do
Begin
s:=s+i;
i:=i+2;
End;
Writeln(S);
Readln;
End.