aboutsummaryrefslogtreecommitdiff
path: root/challenge-171/laurent-rosenfeld/pascal/ch-1.pas
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-171/laurent-rosenfeld/pascal/ch-1.pas')
-rw-r--r--challenge-171/laurent-rosenfeld/pascal/ch-1.pas34
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-171/laurent-rosenfeld/pascal/ch-1.pas b/challenge-171/laurent-rosenfeld/pascal/ch-1.pas
new file mode 100644
index 0000000000..af5026eb30
--- /dev/null
+++ b/challenge-171/laurent-rosenfeld/pascal/ch-1.pas
@@ -0,0 +1,34 @@
+program abundant;
+const
+ max = 20;
+var
+ count, j: integer;
+
+function is_abundant(n: integer): boolean;
+var
+ sum, i: integer;
+begin
+ sum := 0;
+ for i := 2 to round(n/2) do
+ begin
+ if ( n mod i = 0) then
+ sum := sum + i;
+ if (sum > n) then
+ exit(true);
+ end;
+ exit(false);
+end;
+
+begin
+ count := 0;
+ j := 1;
+ while ( count < max ) do
+ begin
+ if (is_abundant(j)) then
+ begin
+ write(j, ' ');
+ count := count + 1;
+ end;
+ j := j + 2;
+ end;
+end.