View Single Post
Old 13-04-2008, 11:25   #7
vietanh279
Rìu Bạc Đôi
 
vietanh279's Avatar
 
Tham gia: Jan 2008
Đến từ: Hà Nội
Bài: 607
VZD: 10.477
Điểm: 448/124 bài viết
Send a message via Yahoo to vietanh279
Default

Chương trình chuẩn như sau:
Code:
program Tim_so_hoan_hao;
uses Crt;
const
    max = 1000;
var
    N, i, sum, mark : integer;

BEGIN
    clrscr;
    writeln('Cac so hoan hao <1000 la : ');
    for N:=1 to max do
        begin
            sum := 0;
            mark := 0;
            for i:=(N div 2) downto 1 do
                begin
                    if (N mod i = 0) then sum := sum + i;
                    if sum>=N then
                        begin 
                              mark := i;
                              break;
                        end;
                end;
            if mark=1 then writeln(N);
        end;
    readln;
END.
__________________
Let's press and all best things will come to you


Life is Football.
Football is MANCHESTER UNITED


http://manutdvn.net/
http://www.vn-zoom.com/groups/fan-football.html


thay đổi nội dung bởi: vietanh279, 13-04-2008 lúc 11:31.
vietanh279 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn