blob: f20aa7c8d288f0c110ed74a376f61284e8eed7f9 (
plain) (
blame)
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
|
var
i, n: int32;
function isperfect(n: int32): boolean;
var
i, s, m: int32;
begin
m := trunc(sqrt(n));
if n mod m > 0 then
s := 1
else if n = m * m then
s := 1 + m
else
s := 1 + m + n div m;
for i := 2 to m - 1 do
if n mod i = 0 then
s := s + i + n div i;
if s = n then
isperfect := true
else
isperfect := false
end;
begin
readln(n);
for i := 2 to n do
if isperfect(i) then
writeln(i)
end.
|