From b7e55e6510690093d61f9cc1152e0330e55fe90b Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Tue, 28 Feb 2017 11:34:35 +0700 Subject: Update others/volume1 --- others/volume1/021.pas | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 others/volume1/021.pas (limited to 'others/volume1/021.pas') diff --git a/others/volume1/021.pas b/others/volume1/021.pas new file mode 100644 index 0000000..f20aa7c --- /dev/null +++ b/others/volume1/021.pas @@ -0,0 +1,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. -- cgit 1.4.1